1 function myErrorHandler($errno, $errstr, $errfile, $errline)
2 {
3 if (!(error_reporting() & $errno)) {
4 // This error code is not included in error_reporting
5 return;
6 }
7
8 switch ($errno) {
9 case E_USER_ERROR:
10 echo "<b>My ERROR</b> [$errno] $errstr<br />\n";
11 echo " Fatal error on line $errline in file $errfile";
12 echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />\n";
13 echo "Aborting...<br />\n";
14 exit(1);
15 break;
16
17 case E_USER_WARNING:
18 echo "<b>My WARNING</b> [$errno] $errstr<br />\n";
19 break;
20
21 case E_USER_NOTICE:
22 echo "<b>My NOTICE</b> [$errno] $errstr<br />\n";
23 break;
24
25 default:
26 echo "Unknown error type: [$errno] $errstr<br />\n";
27 break;
28 }
29
30 /* Don't execute PHP internal error handler */
31 return true;
32 }
->in Main
$my_error_handler = set_error_handler("myErrorHandler");
위와 같이 설정해주게되면
현재 프로그램에서 error가 발생시 myErrorHandler 함수호출.
이때 파라미터들은 자동 매핑.