Our blog
PHP Random Sleep Function with Flush
Sometimes you want your script to pause for a short period of time before repeating a loop or proceeding to the next step. This may be to reduce server load or even to simulate the natural pauses that a person would make whilst browsing a site. This kind of thing is especially true if you are building a system to scrape content such as product information from a suppliers web site and you do not want to hammer their server to death and get your IP banned.
This function will do just that for you. Also it has a built in flush which will help in preventing the script from being regarded as timed out if you are running it from the web browser.
More Reading:
3 Comments
|
good script but flush() is not acting as he says..;( |
|
you may have output buffering turned on try running ob_end_flush(); at the top of your script |
|
James January 6th, 2012 |
Thanks I was looking for something like this as I was using sleep but it still seemed to go to fast on some parts. I am using your function like this incase someone else wanted to know sleep_flush(1); |
RSS Feed
Sarcina Saptamani
January 6th, 2012