Maximum limit for setting a sleep time
Hello Friends,
I would like to know that what is the mamimum limit that can be used for setting the sleep time on my system. If i try to set the sleep time to 47secs, i get a warning message that "sleep time is too long". So, can any body tell me that what is the maximum limit that can be used for setting the sleep time on my system? Does any body knows about it? Kindly help me out to resolve the above issue.
Thanks a lot.
Re: Maximum limit for setting a sleep time
I think the default PHP script execution time is set for 30 seconds at php.ini file. This is the time limit set for all the files to finish its execution. If the file takes more than this set time then the execution of the script will be stopped and error message will be displayed like this.
Quote:
Fatal error: Maximum execution time of 30 seconds exceeded in F:\php_files\t\test.php on line 14
Re: Maximum limit for setting a sleep time
If you are using a screen saver, you can adjust or even turn off the screen saver function. The Energy Saver preferences pane will display a ‘Screen Saver’ button whenever your display is set to go to sleep before your screen saver get activated.
Re: Maximum limit for setting a sleep time
This error occurs because by default the maximum execution time set at php.ini is 30 seconds. If you try to change the above code by adding just one line set_time_limit(60) in it, it will not show the error again. Here is the code by which you can set the mamimum limit on your system.
Quote:
set_time_limit ( 60 ) ;
$t1=time();
sleep(30);
$t2=time();
$t_lapsed=$t2-$t1;
echo "Total time lapsed = $t_lapsed";
Now the script will execute fine without any error message. We can see the total time taken by the script. We can set the time to unlimited value by making it to 0 value. Like this
Quote:
set_time_limit (0);