Home  >  Article  >  Backend Development  >  register_shutdown_function() has no callback?

register_shutdown_function() has no callback?

WBOY
WBOYOriginal
2016-10-17 09:30:181159browse

<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

Reply content:

<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.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn