note 83368 deleted from function.restore-error-handler by googleguy
| From: | googleguy@php.net | Date: | Tue, 22 Oct 2013 11:00:28 +0000 |
| Subject: | note 83368 deleted from function.restore-error-handler by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-197006@lists.php.net to get a copy of this message | ||
Note Submitter: sebagr gmail com
----
I think what Isole wanted to say is that if you push the same error handler twice, then you'll
need to call restore_error_handler() twice if you want to get rid of it:
<?php
function custom_error_handler(){
echo 'My error handler';
return false;
}
set_error_handler('custom_error_handler'); // Stack is: <default error handler> |
custom_error_handler
set_error_handler('custom_error_handler'); // Stack is: <default error handler> |
custom_error_handler | custom_error_handler
trigger_error('error', E_USER_WARNING); // Will print 'My error handler';
restore_error_handler(); // The stack is <default error handler> | custom_error_handler
trigger_error('error', E_USER_WARNING); // Will still print 'My error handler',
since the stack is still dirty with our first custom_error_handler.
restore_error_handler(); // The stack is <default error handler>
trigger_error('error', E_USER_WARNING); // Now this will trigger the default error
handler.
?>