2008年5月22日 星期四

apache 如何顯示PHP 的錯誤訊息呢?

部份虛擬主機商把錯誤訊息給關起來, 所以就沒辦法偵錯啦!
若是自行架設的主機 , 可以去修改 php.ini 的設定如下:


; - display_errors = Off [Security]
; With this directive set to off, errors that occur during the execution of
; scripts will no longer be displayed as a part of the script output, and thus,
; will no longer be exposed to remote users. With some errors, the error message
; content may expose information about your script, web server, or database
; server that may be exploitable for hacking. Production sites should have this
; directive set to off.

; Print out errors (as a part of the output). For production web sites,
; you're strongly encouraged to turn this feature off, and use error logging
; instead (see below). Keeping display_errors enabled on a production web site
; may reveal security information to end users, such as file paths on your Web
; server, your database schema or other information.
display_errors = On

若是不行那只好在php程式前面加上這幾行了...

ini_set('display_errors', 1); //顯示錯誤訊息
ini_set('log_errors', 1); //錯誤log 檔開啟
ini_set('error_log', dirname(__FILE__) . '/error_log.txt'); //log檔位置
error_reporting(E_ALL); //錯誤回報


【下列文章您可能也有興趣】

沒有留言: