htaccess怎么关闭php错误

藏色散人
풀어 주다: 2023-03-11 12:22:02
원래의
1799명이 탐색했습니다.

htaccess关闭php错误的方法:首先找到“.htaccess”文件;然后将“php_flag display_startup_errors off”等代码放到对应目录中的“.htaccess”文件即可。

htaccess怎么关闭php错误

本文操作环境:windows7系统、PHP7.1版,DELL G3电脑

htaccess怎么关闭php错误?

用.htaccess关闭PHP错误显示

将以下相应代码放到对应目录中的.htaccess文件,即可实现相应功能。

关闭错误显示:

php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
php_value docref_root 0
php_value docref_ext 0
로그인 후 복사

只显示PHP错误:

php_flag  display_errors        on
php_flag  display_startup_errors on
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 E_STRICT
4096 E_RECOVERABLE_ERROR
로그인 후 복사

要把错误保存到日志文件中,可以这样设置:

# enable PHP error logging
php_flag  log_errors on
php_value error_log  /home/path/public_html/domain/PHP_errors.log
로그인 후 복사

然后,可以设置不允许访问.log文件:

# prevent access to PHP error log
Order allow,deny
Deny from all
Satisfy All
로그인 후 복사

设置错误日志的最大体积,以bytes为单位:

# general directive for setting max error size
log_errors_max_len integer
로그인 후 복사

综合上述,.htaccess的PHP错误显示设置汇总:

# PHP error handling for production servers
# disable display of startup errors
php_flag display_startup_errors off
# disable display of all other errors
php_flag display_errors off
# disable html markup of errors
php_flag html_errors off
# enable logging of errors
php_flag log_errors on
# disable ignoring of repeat errors
php_flag ignore_repeated_errors off
# disable ignoring of unique source errors
php_flag ignore_repeated_source off
# enable logging of php memory leaks
php_flag report_memleaks on
# preserve most recent error via php_errormsg
php_flag track_errors on
# disable formatting of error reference links
php_value docref_root 0
# disable formatting of error reference links
php_value docref_ext 0
# specify path to php error log
php_value error_log /home/path/public_html/domain/PHP_errors.log
# specify recording of all php errors
php_value error_reporting 999999999
# disable max error string length
php_value log_errors_max_len 0
# protect error log by preventing public access
Order allow,deny
Deny from all
Satisfy All
로그인 후 복사

以下则是适合开发者应用的设置:

# 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 /home/path/public_html/domain/PHP_errors.log
php_value error_reporting 999999999
php_value log_errors_max_len 0
Order allow,deny
Deny from all
Satisfy All
로그인 후 복사

推荐学习:《PHP视频教程

위 내용은 htaccess怎么关闭php错误의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
최신 이슈
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!