执行自定义函数,捕捉PHP脚本执行时的错误。
~~~
<?php
//来源:http://www.oschina.net/code/snippet_854149_26608
error_reporting(0);
function _rare_shutdown_catch_error(){
$_error=error_get_last();
if($_error && in_array($_error['type'],array(1,4,16,64,256,4096,E_ALL))){
echo '致命错误:'.$_error['message'].'</br>';
echo '文件:'.$_error['file'].'</br>';
echo '在第'.$_error['line'].'行</br>';
}
}
register_shutdown_function("_rare_shutdown_catch_error");
?>
~~~