I've seen a lot of questions regarding this error in PHP. But everywhere the solution is given as to set the time limit.
But what I want to do is, to detect the error and if it occurs then switch to another course of action. I mean, if my requests exceed my maximum time set, then it should not give an error message and stop but continue executing some other block of codes. How may I achieve that?
=======
I just found this code is a site, can it help?
<?php
//open error reporting, the error message is required in this script
error_reporting(1);
//for testing, set maximum execution to 1 second
set_time_limit(1);
//turn on output buffering and set callback function
ob_start('callback');
//------------------------------------------------------------------------------
//main program(dead loop)
while (true);
//script completed(impossible)
echo 'Completed!';
//------------------------------------------------------------------------------
/**
* output callback, execute when end of the request
*
* @param string $buffer
* @return string
*/
function callback($buffer) {
if (false !== (stripos($buffer,'<b>Fatal error</b>'))) {
if (false !== (stripos($buffer,'Maximum execution'))) {
$buffer = 'ycTIN.com , Server Busy';
} else {
$buffer = 'ycTIN.com , Server Internal Error';
}
}
return $buffer;
}
?>