The restore_error_handler Function

The restore_error_handler function restores the previous error handler, which was set before calling set_error_handler. This function does not take any parameters and always returns true.

Syntax

phprestore_error_handler();

Example

Let's create a custom error handler and then restore the standard one:

php<?php
  function customErrorHandler($errno, $errstr) {
    echo "Custom error: [$errno] $errstr";
  }
  
  set_error_handler("customErrorHandler");
  echo $test; // Will call the custom handler
  
  restore_error_handler();
  echo $test; // Now will call the standard PHP handler
?>

Example

Let's check the return value of the function:

php<?php
  $res = restore_error_handler();
  var_dump($res);
?>

Code execution result:

phptrue