How to use restore error handler in PHP

This article describe about restore_error_handler() function in PHP.
  • 1537

restore_error_handler() function

This function restore the previous error handler.

Restore the previous error handler after changing it with the set_error_handler() function it the main purpose of restore_error_handler() function.

This function always return TRUE.

Syntax

restore_error_handler()

 

Example

 

<html>
<body>
<?php
function customError($errno, $errstr, $errfile, $errline)
{
echo "<b>Custom error:</b> [$errno] $errstr<br />";
echo " Error on line $errline in $errfile<br />";
}
set_error_handler("customError");

$test=2;
if ($test>1)
{
trigger_error("A custom error has been triggered");
}
restore_error_handler();
if ($test>1)
{
trigger_error("A custom error has been triggered");
}
?>
</body>
</html>

Output

pic19.jpg

You may also want to read these related articles Click here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.