2009-08-07 48 views
1

IM在suse11.0我的問題PHP的工作是當我輸入一個錯誤的語法或查詢它不顯示在此situtaion所示PHP的犯規顯示錯誤

感謝

+0

可能重複[如何獲得在PHP有用的錯誤信息?(http://stackoverflow.com/questions/845021/how-to-get-useful-error-messages-in- php) – Jocelyn 2012-11-16 00:32:08

回答

3

錯誤只空白頁它幾乎肯定在php.ini中禁用display_errors的情況。

這是產品服務器上的一件好事,並且使開發系統基本無法使用。

對於你可能要添加這些行之一你php.ini文件開發系統:

error_reporting = E_ALL & ~E_NOTICE 

error_reporting = E_ALL 
+0

爲了補充說明,你可能會發現Web服務器日誌中的錯誤(對於Apache,這通常是/ var/log/httpd/error_log) – Amber 2009-08-07 19:45:55

0

確保使用error_reporting在php.ini

已開啓
error_reporting = E_ALL | E_STRICT 
0

請確保在您的php.ini文件中顯示了display_errors並將error_reporting設置爲E_ALL。

0

與啓動腳本:

<?php 
    ini_set ('display_errors', 1); 
    error_reporting (E_ALL | E_STRICT); 
?> 
6

你可能配置error_reportingsee also),並啓用錯誤(見display_errorsini_set)的顯示 - 至少在開發機器上

在php.ini文件,你會使用

error_reporting = E_ALL | E_STRICT 
display_errors = On 
html_errors = On 

或者,在你的PHP代碼:

error_reporting(E_ALL | E_STRICT); 
ini_set('display_errors', 'On'); 

您可能還需要在開發機器上安裝Xdebug,獲得不錯的stacktraces wehn錯誤/異常發生


當然,你生產的機器上,你可能不希望顯示錯誤;這樣,將有根據環境;-)

2

創建例如test.php的文件與此內容進行配置:

<?php 
phpinfo(); 
?> 

執行它在瀏覽器和搜索在php.ini文件位於。 比在php.ini中打開錯誤報告和顯示錯誤。

0

雖然其他答案能夠回答您的問題,但我只想指出,最好提供自己的錯誤檢查例程(或代碼),以便您的腳本將向用戶顯示令人愉快的錯誤消息。 像

[email protected]_query($some_query); 
if(!$result){ 
    if($debugging==TRUE){ 
     echo($some_query.'<br>'.mysql_error());//shows error in debugging mode 
    } 
    else{ 
    log_error()// error logging function 
     die('there was a problem with your request the problem has been logged and we are working on it');//or something like that 

    } 
} 
//no error 
more code