Ogu*_*nwu 105 php error-handling .htaccess
我正在网上测试一个网站.
现在,错误没有显示(但我知道它们存在).
我只能访问该.htaccess
文件.
如何使用我的.htaccess
文件显示所有错误
编辑
我将这些行添加到我的.htaccess
:
php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on
Run Code Online (Sandbox Code Playgroud)
和页面现在显示
内部服务器错误
sil*_*lex 178
的.htaccess:
php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on
php_flag log_errors on
php_value error_log /home/path/public_html/domain/PHP_errors.log
Run Code Online (Sandbox Code Playgroud)
UFT*_*mmy 39
php_flag display_errors on
Run Code Online (Sandbox Code Playgroud)
要打开错误的实际显示.
要设置要显示的错误类型,您需要使用:
php_value error_reporting <integer>
Run Code Online (Sandbox Code Playgroud)
结合此页面中的整数值:http://php.net/manual/en/errorfunc.constants.php
请注意,如果对整数使用-1,它将显示所有错误,并在添加新类型的错误时进一步证明.
Ash*_*ish 16
我想在现有答案中添加更多细节:
# PHP error handling for development servers
php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on
php_flag log_errors on
php_flag ignore_repeated_errors off
php_flag ignore_repeated_source off
php_flag report_memleaks on
php_flag track_errors on
php_value docref_root 0
php_value docref_ext 0
php_value error_log /full/path/to/file/php_errors.log
php_value error_reporting -1
php_value log_errors_max_len 0
Run Code Online (Sandbox Code Playgroud)
授予日志文件777或755权限,然后添加代码
<Files php_errors.log>
Order allow,deny
Deny from all
Satisfy All
</Files>
Run Code Online (Sandbox Code Playgroud)
在.htaccess结束时.这将保护您的日志文件.这些选项适用于开发服务器.对于生产服务器,您不应向最终用户显示任何错误.因此,将显示标志更改为关闭.
有关更多信息,请访问以下链接:通过htaccess进行高级PHP错误处理