用. htaccess设置显示php错误
使用。htaccess可以在某种程度上更改PHP的错误显示的设置,实际上,相当于更改PHP . ini的参数,很是方便。
将以下相应代码放到对应目录中的。htaccess文件,即可实现相应功能。
关闭错误显示
:
php_flag display_startup_errors
php_flag display_errors
php_flag html_errors
php_value docref_root 0
php_value docref_ext 0
只显示PHP错误
:
php_flag , display_errors ,,,,,,,
php_flag display_startup_errors
php_value error_reporting ,,,,,,, 2047
其中,“2047”为要显示的错误的级别,详细表格如下:
1,E_ERROR
2,E_WARNING
4,E_PARSE
8,E_NOTICE
16,E_CORE_ERROR
32,E_CORE_WARNING
64年,E_COMPILE_ERROR
128年,E_COMPILE_WARNING
256年,E_USER_ERROR
512年,E_USER_WARNING
1024年,E_USER_NOTICE
2047年,E_ALL
2048年,代码
4096年,E_RECOVERABLE_ERROR
要把错误保存到日志文件中
,可以这样设置:
#,enable PHP  error 日志记录
php_flag log_errors
php_value error_log ,/home/道路/public_html/域/PHP_errors.log
然后,可以设置不允许访问. log文件
:
#,prevent access 用PHP error 日志
& lt; Files  PHP_errors.log>
Order 允许,拒绝
Deny 得到所有
Satisfy 所有
& lt;/Files>
设置错误日志的最大体积
,以字节为单位:
#,general directive  for setting max error 大小
log_errors_max_len 整数
综合上述,. htaccess的PHP错误显示设置汇总
:
#,PHP error  handling for production 服务器
#,disable display  of startup 错误
php_flag display_startup_errors
#,disable display  of all other 错误
php_flag display_errors
#,disable html  markup of 错误
php_flag html_errors
#,enable logging  of 错误
php_flag log_errors
#,disable ignoring  of repeat 错误
php_flag ignore_repeated_errors
#,disable ignoring  of unique source 错误
php_flag ignore_repeated_source
#,enable logging  of php memory 泄漏
php_flag report_memleaks
#,preserve most  recent error via php_errormsg
php_flag track_errors
#,disable formatting  of error 参考文档链接
php_value docref_root 0
#,disable formatting  of error 参考文档链接
php_value docref_ext 0
#,specify path 用php error 日志
php_value error_log /home/道路/public_html/域/PHP_errors.log
#,specify recording  of all php 错误
php_value error_reporting 999999999
#,disable max  error string 长度
php_value log_errors_max_len 0
#,protect error  log by preventing public 访问
& lt; Files /home/道路/public_html/域/PHP_errors.log>
Order 允许,拒绝
Deny 得到所有
Satisfy 所有
& lt;/Files>
以下则是适合开发者应用的设置:
#,PHP error  handling for development 服务器
php_flag display_startup_errors
php_flag display_errors
php_flag html_errors
php_flag log_errors
php_flag ignore_repeated_errors
php_flag ignore_repeated_source
php_flag report_memleaks
php_flag track_errors
php_value docref_root 0
php_value docref_ext 0
php_value error_log /home/道路/public_html/域/PHP_errors.log
php_value error_reporting 999999999
php_value log_errors_max_len 0
& lt; Files /home/道路/public_html/域/PHP_errors.log>
Order 允许,拒绝
Deny 得到所有
Satisfy 所有
& lt;/Files>
总之,通过。htaccess设置显示PHP错误来控制PHP错误是否显示似乎更方便。