htaccess怎麼關閉php錯誤
htaccess
htaccess關閉php錯誤的方法:先找到「.htaccess」檔案;然後將「php_flag display_startup_errors off」等程式碼放到對應目錄中的「.htaccess」檔案即可。
本文操作環境: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中文網其他相關文章!
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章
<🎜>:種植花園 - 完整的突變指南
3 週前
By DDD
<🎜>:泡泡膠模擬器無窮大 - 如何獲取和使用皇家鑰匙
3 週前
By 尊渡假赌尊渡假赌尊渡假赌
如何修復KB5055612無法在Windows 10中安裝?
3 週前
By DDD
北端:融合系統,解釋
3 週前
By 尊渡假赌尊渡假赌尊渡假赌
Mandragora:巫婆樹的耳語 - 如何解鎖抓鉤
3 週前
By 尊渡假赌尊渡假赌尊渡假赌

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)