Voting

: min(zero, three)?
(Example: nine)

The Note You're Voting On

steve962 at gmail dot com
7 years ago
Be careful when using the return value to this function. Because it returns the old handler, you may be tempted to do something like:

<?php
function do_something()
{
$old = set_error_handler(“my_error_handler”);
// Do something you want handled by my_error_handler
set_error_handler($old);
}
?>

This will work, but it will bite you because each time you do this, it will cause a memory leak as the old error handler is put on a stack for the restore_error_handler() function to use.

So always restore the old error handler using that function instead:

<?php
function do_something()
{
set_error_handler(“my_error_handler”);
// Do something you want handled by my_error_handler
restore_error_handler();
}
?>

<< Back to user notes page

To Top