我正在尝试用自定义函数替换内置的 php shutdown_function 。
它工作得很好,但是,它仍然在我的新错误消息上方输出原始错误(内置错误)。
<?php
function shutdown_output() {
$error = error_get_last();
if($error !== NULL) {
echo "ERROR";
exit();
} else {
echo "NO ERROR";
}
}
// Set the error reporting:
register_shutdown_function('shutdown_output');
// test.php does not exist, just here to get a critical error
require_once("test.php");
?>
有任何想法吗?
正如评论中已经提到的,使用register_shutdown_function
不会覆盖内置的错误处理(与set_error_handler
也没有)。
如果您不想看到原始消息,请在您的php.ini
using display_errors = 0
。或者在您的脚本中使用ini_set('display_errors', 0);
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)