I have method, in this method may be happened fatal error, for catching this error I make this
class a {
function shutDownFunction() {
$error = error_get_last();
if ($error['type'] == 1) {
echo "this is fatal error";
}
}
function terribleFunction () {
register_shutdown_function(array($this,'shutdownFunction'));
// here is code, wich may causes fatal error
}
}
Okay, this understand, but I need pass argument from terribleFunction
to shutDownFunction
. How to make this?
First you need to specify that shutDownFunction
should accept a parameter.
function shutDownFunction($var)
Then you can call register_shutdown_function
as so
register_shutdown_function(array($this, 'shutdownFunction'), $myVar);
Documentation is here and there are examples in the comments.