这种方法对于 Parse error 是无效的,试试下面的代码:
<?php /* php.ini display_errors: On Parse error: syntax error, unexpected end of file in D:\wamp\www\display-errors\display-errors2.php on line 18 php.ini display_errors: Off 500 Internal Server Error */ ini_set('display_errors', 'On'); error_reporting(E_ALL); rrt
代码:
php_flag display_startup_errors on php_flag display_errors on然而,可能会出现 Internal Server Error。
网上的资料:
Assuming PHP is running, create a phpinfo() file, and check the server method. php_flag will only work if mod_php is being used, ie. PHP is an Apache Module, if it's FCGI, it will not work.
我查看了 phpinfo(),没有查找到 mod_php,并看到:
在另一台主机上,作为反例,查找到了 mod_php:
在 .htaccess 中开启报错,需要服务器是 mod_php 模式,而不是 CGI/FastCGI 模式。
我的理解是:mod_php 模式下,php 作为 Apache 的一个模块,因此可以在 .htaccess 中进行 php_*(如 php_flag) 之类的设置。否则,php_* 这种命令会导致错误。
示例代码:
<?php ini_set('display_errors', 'On'); error_reporting(E_ALL); include 'example.err-inc.php';
墨之科技,版权所有 © Copyright 2017-2027
湘ICP备14012786号 邮箱:ai@inksci.com