Alf*_*lfo 1 php error-handling
每当遇到PHP中的简单解析错误时,我的服务器(Apache2,PHP5)都会返回一个带有Header Code 500的空白页面.例如:
<?php functiondoesnotexist(); ?>
Run Code Online (Sandbox Code Playgroud)
要么
<?php echo 'with2semicolons';; ?>
Run Code Online (Sandbox Code Playgroud)
不输出其中一个橙色表告诉我什么是错的,服务器只是保释.
我检查了Apache错误日志,它确实告诉我错误(例如Undefined function functiondoesnotexist()).
我怎么能阻止这种行为?我php.ini(据我所知)未受影响.
您可以在php.ini文件中设置这些错误变量:
error_reporting = E_ALL | E_STRICT
display_errors = On
Run Code Online (Sandbox Code Playgroud)
和/或在需要时在PHP脚本的开头覆盖它们:
ini_set('display_errors', 1);
error_reporting(E_ALL | E_STRICT);
Run Code Online (Sandbox Code Playgroud)