本篇內(nèi)容介紹了“htaccess如何關(guān)閉php錯(cuò)誤”的有關(guān)知識(shí),在實(shí)際案例的操作過程中,不少人都會(huì)遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!
成都創(chuàng)新互聯(lián)主營平塘網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,重慶App定制開發(fā),平塘h5微信小程序開發(fā)搭建,平塘網(wǎng)站營銷推廣歡迎平塘等地區(qū)企業(yè)咨詢
htaccess關(guān)閉php錯(cuò)誤的方法:首先找到“.htaccess”文件;然后將“php_flag display_startup_errors off”等代碼放到對(duì)應(yīng)目錄中的“.htaccess”文件即可。
本文操作環(huán)境:windows7系統(tǒng)、PHP7.1版,DELL G3電腦
htaccess怎么關(guān)閉php錯(cuò)誤?
用.htaccess關(guān)閉PHP錯(cuò)誤顯示
將以下相應(yīng)代碼放到對(duì)應(yīng)目錄中的.htaccess文件,即可實(shí)現(xiàn)相應(yīng)功能。
關(guān)閉錯(cuò)誤顯示:
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錯(cuò)誤:
php_flag display_errors on php_flag display_startup_errors on php_value error_reporting 2047
其中,“2047”為要顯示的錯(cuò)誤的級(jí)別,詳細(xì)表格如下:
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
要把錯(cuò)誤保存到日志文件中,可以這樣設(shè)置:
# enable PHP error logging php_flag log_errors on php_value error_log /home/path/public_html/domain/PHP_errors.log
然后,可以設(shè)置不允許訪問.log文件:
# prevent access to PHP error log Order allow,deny Deny from all Satisfy All
設(shè)置錯(cuò)誤日志的最大體積,以bytes為單位:
# general directive for setting max error size log_errors_max_len integer
綜合上述,.htaccess的PHP錯(cuò)誤顯示設(shè)置匯總:
# 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
以下則是適合開發(fā)者應(yīng)用的設(shè)置:
# 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
“htaccess如何關(guān)閉php錯(cuò)誤”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí)可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!