PHP头条
热点:

探讨捕获php错误信息方法的详解


PS:
1.捕获PHP语法错误
2.严重错误

用正常的 set_error_handle无法捕获此两类错误,这是捕获此类错误的技巧
代码如下:
//test.php 页面
error_reporting(0);
register_shutdown_function('PageOnShutdown');
include('error_test.php');
function PageOnShutdown()
{
$msg = error_get_last();
print_r($msg);

}

//error_test.php 页面

$a = 1 + 2

$b

然后 输出 test.php 打印出
Array ( [type] => 4 [message] => parse error [file] => D:\web\tbc\error_test.php [line] => 5 )
再根据 获得 $msg 写入日志操作就可以了

www.phpzy.comtrue/php/17207.htmlTechArticle探讨捕获php错误信息方法的详解 PS: 1.捕获PHP语法错误 2.严重错误 用正常的 set_error_handle无法捕获此两类错误,这是捕获此类错误的技巧 代码如下: //test.php 页面 error_reporting(0); register_...

相关文章

PHP之友评论

今天推荐