2016-12-16 41 views
1

我最近在Ubuntu上安裝了apache2和php5.6 14.04 在apache和cli的php.ini中,我設置了正確的配置(I認爲):Ubuntu 14.04上的php5.6不顯示錯誤,默認錯誤處理程序

error_reporting = E_ALL 
display_errors = On 
display_startup_errors = On 
log_errors = On 
track_errors = On 
error_log = "/var/log/php_errors.log" 

error_log指向的文件是可寫的。

而且我可以在命令linke或web瀏覽器中顯示錯誤。

我spended小時搜索網頁,唯一覺得我設法工作是手動設置在一個腳本處理的錯誤:

set_error_handler("var_dump"); 

當改變錯誤處理一些信息打印(mysql的錯誤我被迫):

$ php informe_presupuestos.php 
/var/www/buv/lib/sqlquery.class.php:88: 
int(2) 
/var/www/buv/lib/sqlquery.class.php:88: 
string(72) "mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given" 
/var/www/buv/lib/sqlquery.class.php:88: 
string(66) "/var/www/buv/lib/sqlquery.class.php" 
/var/www/buv/lib/sqlquery.class.php:88: 
int(88) 
/var/www/buv/lib/sqlquery.class.php:88: 
array(1) { 
    'result_id' => 
    string(4) "pres" 
} 

我也嘗試restore_error_handler()在腳本的開始,但不起作用。

有關如何啓用錯誤顯示的任何想法?

回答

0

小有線你有什麼,因爲normaly它應該工作,但我現在不什麼在你的.php所以mybe試試這個:

<?php 
error_reporting(E_ALL); 
ini_set("display_errors", 1); 
register_shutdown_function(function(){while(ob_get_level()>0)ob_end_flush();}); 

順便說一下,什麼是/var/log/php_errors.log的內容,而你是測試你的腳本。

注意從http://php.net/manual/en/function.set-error-handler.php

以下錯誤類型不能與用戶定義的函數來處理:E_ERROR,E_PARSE,E_CORE_ERROR,E_CORE_WARNING,E_COMPILE_ERROR,E_COMPILE_WARNING,最E_STRICT的文件中提出,其中的set_error_han dler( ) 叫做。

所以,如果你現在不真實,你最好使用默認的錯誤處理程序。

+0

我在腳本開始時試過了你的代碼,沒有顯示任何內容。錯誤日誌是空的。 – Sergi

+0

僅用於完整驗證。請在'register'行後添加'new NonClass();'並再次嘗試並說出是否有什麼東西。 – JustOnUnderMillions

+0

也用於'php.ini':你必須在更改'service apache2 restart'後重新啓動apache。你是否只更改'cli' php.ini或'cgi'版本?或者也許混合這兩個? – JustOnUnderMillions