PHP - Last Call

Is there a way to tell PHP to run one last function or somehow override some error handler in case of a fatal error? I have a cron that has a main entry point:

$obj = new obj();
$obj->run();
exit;

Will there be a wrap in an attempt to catch a trick if I do not explicitly throw errors? All I want is PHP to make something as simple as creating a txt file containing a fatal error, or even just creating an empty file called "failed.txt" or something like that.

Thank!

+3
source share
6 answers

cron. script php.ini, PHP STDERR STDOUT.

php -h

.

cron , - .

, php.ini. , .

+3

- .

E_ERROR, .

, . . , , .

+2

You can perform custom error handling in PHP. Check out the manual at: http://php.net/function.set-error-handler . This is a fairly simple application.

+1
source

Use register_shutdown_function()to register the function executed as the last call. This will cause an error to occur or not.

See http://php.net/manual/function.register-shutdown-function.php for details .

+1
source

Use

try 
{ 
    //Code
} 
catch(Exception $e)
{
     //Execute on error
}
0
source

All Articles