问个简单的php错误处理的问题哈

WBOY
Release: 2016-06-06 20:35:35
Original
1128 people have browsed it

代码一:
echo $a;
echo print_r(error_get_last(),true);

错误提示为:
问个简单的php错误处理的问题哈

代码二:
set_error_handler('appError');

function appError($errno, $errstr, $errfile, $errline)
{
echo 'appError '.$errno.$errstr.'['.print_r(error_get_last(),true).']
';
}

echo $a;

错误提示为:
问个简单的php错误处理的问题哈
为什么代码二error_get_last()捕捉不到错误呢???

回复内容:

代码一:
echo $a;
echo print_r(error_get_last(),true);

错误提示为:
问个简单的php错误处理的问题哈

代码二:
set_error_handler('appError');

function appError($errno, $errstr, $errfile, $errline)
{
echo 'appError '.$errno.$errstr.'['.print_r(error_get_last(),true).']
';
}

echo $a;

错误提示为:
问个简单的php错误处理的问题哈
为什么代码二error_get_last()捕捉不到错误呢???

我好像明白了,当错误被自定义的appError承接了,error_get_last()就扑捉不到错误了,即使error_get_last()在appError中,嘻嘻,我真是太聪明了。

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