Home > Article > Backend Development > register_shutdown_function() has no callback?
<code><?php register_shutdown_function("myerror"); function myerror(){ error_get_last(); echo "here"; } function test(){} function test(){}</code>
In this case, register_shutdown_function() is not triggered. Why? Thank you
<code><?php register_shutdown_function("myerror"); function myerror(){ error_get_last(); echo "here"; } function test(){} function test(){}</code>
In this case, register_shutdown_function() is not triggered. Why? Thank you
The
register_shutdown_function
function will only be called when the script exits normally or the user calls a method such as exit
. Note that it exits normally. When an error occurs in the script (the above method has the same name), it will not be triggered.
Equivalent to every time you call register_shutdown_function
, put the function
you want to register into [pretend it’s a queue], wait until the script exits normally or displays the call exit
, and then pull out the registered function
If an error occurs in your script during execution, the error will be thrown directly.