関数 restore_error_handler

関数 restore_error_handler は、 set_error_handler を呼び出す前に設定されていた前のエラーハンドラーを復元します。 この関数はパラメーターを受け取らず、常に true を返します。

構文

phprestore_error_handler();

例

カスタムエラーハンドラーを作成し、その後標準のハンドラーを復元します:

php<?php
  function customErrorHandler($errno, $errstr) {
    echo "カスタムエラー: [$errno] $errstr";
  }
  
  set_error_handler("customErrorHandler");
  echo $test; // カスタムハンドラーを呼び出す
  
  restore_error_handler();
  echo $test; // ここでPHPの標準ハンドラーを呼び出す
?>

例

関数の戻り値を確認します:

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

コードの実行結果:

phptrue