【发布时间】:2018-04-26 05:01:42
【问题描述】:
在下面的代码中,我在网页输出中获得了“AAA”(仅),而“BBB”则进入了 error.log 文件(仅)。 我希望 both 转到 error.log 文件,因此用户在我这样做时不会看到潜在的错误。怎么样?
<?php
ini_set('display_errors','1');
ini_set('error_log','error.log');
error_reporting(-1); // all
trigger_error('AAA');
error_log('BBB');
?>
(注意:这类似于http://stackoverflow.com/questions/9921643/how-to-make-provoke-an-php-error-in-php-error-log,但不一样。)
【问题讨论】:
-
trigger_error的概念是在User级别。 “trigger_error - 生成用户级错误/警告/通知消息”。如果是这样,你就用错了。
-
那么,不使用 'error_log' 函数,我如何才能测试“适当的”潜在错误进入我的error.log 文件?
-
您可以创建自定义错误处理程序。但我可以问为什么“不使用error_log”,毕竟这是它的目的。
-
"errors go to my error.log file without using the error_log" 意思是——我想知道我没想到的错误:调用不存在的函数、语法错误、运行时错误-- 但我不想让用户知道他们。