I posted this in coding but maybe it would be better in Newbie because nobody is responding. :bemused:
I am newbie and was working through an example from Core PHP that tests connection status.
I got a page of lines of "X's" as would be expected until the maximum time setting is hit. Then I get the following messages at the end and I didn't get the final print command that the "Fake Task finished." I am wondering why the print command failed:
Fatal error: Maximum execution time of 3 seconds exceeded in /home/omgma/public_html/Fresh_start/test.php5 on line 75
Here is the code I ran:
PHP Code:
function cleanUp()
{
$status = connection_status();
$statusMessage = date("Y-m-d H:i:s");
$statusMessage .= " Status was $status. ";
if($status & CONNECTION_ABORTED)
{
$statusMessage .= "The script was aborted. ";
}
if($status & CONNECTION_TIMEOUT)
{
$statusMessage .= "The script timed out. ";
}
$statusMessage .= "\n";
//write status to log file
error_log($statusMessage, 3, "/tmp/status.log");
return(TRUE);
}
//set cleanUp to the shutdown function
register_shutdown_function("cleanUp");
set_time_limit(3);
//wait out the max execution time
while(TRUE)
{
for($i=1; $i < 80; $i++)
{
print('x');
}
print('<br>');
}
print("Fake task finished.\n");
So if the max execution time is set in the code to 3 seconds wont it always generate a fatal error when 3 seconds are up and thus fail to print the the fake task line?
What have I got mucked up in here? 😕