这是我的代码:
echo 'foo';
error_reporting(E_ALL);
echo 'this line doesnt end in a semi colon'
echo 'i should get an error here';
当我运行它时,我没有收到任何错误。
不知道这是怎么回事?
这是我的代码:
echo 'foo';
error_reporting(E_ALL);
echo 'this line doesnt end in a semi colon'
echo 'i should get an error here';
当我运行它时,我没有收到任何错误。
不知道这是怎么回事?
ini_set('display_errors', 1);
请注意,如果您在有语法错误的文件中执行此操作,它将不起作用,因为它永远不会被执行。你也可以在 php.ini 中设置为 true(不推荐用于生产服务器),或者如果你使用 Apache,在 .htaccess 中:
php_flag display_errors 1
error_reporting 指令不会帮助您在屏幕上显示错误消息。它负责显示哪个错误,而不是where。
如果您的 PHP 作为 Apache 模块运行(很可能是这样),则将以下行添加到.htaccess
文件中:
php_value display_errors 1
当您切换到生产时,将其更改为
php_value display_errors 0
php_value log_errors 1
并在错误日志中观察它们。
您是否有任何类型的关闭挂钩、错误处理函数或全局异常捕获器正在运行?
在大型框架中,语法错误可能很奇怪:)