I'm trying to investigate the way PHP behaves in relation to timeouts and included scripts. PHP seems to do very strange things when scripts that include other scripts timeout, or when the included scripts themselves timeout. Just wondering if anyone else has ever investigated this world of mystery, or if they would like to join me in my quest into the unknown!!....??
It appears that in some cases php will return a completely balnk page when a script times out (no "Fatal error...." message, despite 'display errors' being well and truly turned on). Or sometimes it will display the error message. I haven't quite figured out what it is that causes these different behaviors.
It would seem that if you do this:
[PHP]set_time_limit(40);
include 'some_script.php';[/PHP]
For those of you without super-human, badly-coloured-code-reading abilities that's:
<?php set_time_limit(40);
include 'some_script.php'; ?>
Then 'some_script.php' is also given a maximum execution time of 40 seconds.
And this is the bit that's really strange...
If you have this:
[PHP]set_time_limit(20);
include 'tedious_loop.php';
include 'tedious_loop.php';
include 'tedious_loop.php';
include 'tedious_loop.php';[/PHP]
(set_time_limit(20); include 'tedious_loop.php' 4 times)
And 'tedious_loop.php' takes 7 seconds to execute, e.g.:
[PHP]$time=microtime(1)+7;
while(microtime(1)<$time)
{
//do nothing
}[/PHP]
(a loop that does nothing for 7 seconds)
Then your script will sometimes timeout, and sometimes wont (despite the fact that the whole thing will always take 28 seconds). The time that 'tedious_loop.php' takes to execute is not counted as part of the execution time of your main script. Well not entirely anyway. But like I said, sometimes it will cause your script to timeout and sometimes it wont. Can anyone else shed any light on this?