Home >php教程 >php手册 >探讨捕获php错误信息方法的详解

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

WBOY
WBOYOriginal
2016-06-06 20:31:23953browse

本篇文章是对捕获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 写入日志操作就可以了 ,服务器空间
Statement:
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