PHP 错误处理函数实例


PHP 错误处理函数实例

<?php
   function customError($errno, $errstr, $errfile, $errline) {
      echo "Custom error: [$errno] $errstr\n";
      echo "Error on line $errline in $errfile\n";
      echo "Ending Script";

      die();
   }

   //set error handler
   set_error_handler("customError");
   $test = 0;

   //trigger error
   if ($test >  -1) {
      trigger_error("A custom error has been triggered");
   }
?>