6

以下脚本未向浏览器输出错误消息。相反,它会导致 HTTP 错误 500 响应。

<?php
error_reporting(E_ALL);
ini_set('display_errors', 'On');

phpinfo();

echo "test" asdf // This should error
?>

想法?这是 ubuntu 上的基本 php5/apache2 安装。httpd.conf 为空白,没有 .htaccess 文件。

error.log 文件显示错误消息:

语法错误,意外的 T_STRING,需要 ',' 或 ';'

哪个是对的。

4

1 回答 1

3
<?php
error_reporting(-1);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);

phpinfo();

echo "test" asdf // This should error
?>

error_reporting -1节目中甚至更多E_ALL,因为display_errors我使用了 value1而不是On.

http://php.net/manual/en/function.error-reporting.php http://www.php.net/manual/en/errorfunc.configuration.php#ini.display-errors

编辑:我得到了答案!

如果脚本存在阻止其运行的解析错误,这也会阻止它 > 更改 PHP 设置。

https://serverfault.com/questions/242662/ubuntu-php5-apache2-displaying-500-error-instead-of-error-message

于 2011-03-10T05:25:23.150 回答