Home > Backend Development > PHP Tutorial > 探讨捕获php错误信息方法的详解_PHP

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

WBOY
Release: 2016-06-01 12:06:24
Original
894 people have browsed it

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 写入日志操作就可以了

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template