2013-06-05 84 views
33

這是我的PHP腳本 -的error_reporting(E_ALL)不會產生錯誤

<?php 
    error_reporting(E_ALL); 
    echo('catch this -> ' ;. $thisdoesnotexist); 
?> 

,顯然不應該展示一些東西,如果它是被執行。

我看到的只是一個空白頁面。 error_reporting(E_ALL)爲什麼不起作用?

<?php 
    ini_set("display_errors", "1"); 
    error_reporting(E_ALL); 
    echo('catch this -> ' ;. $thisdoesnotexist); 
?> 

也沒有幫助。我得到的只是一個空白頁面。

我去過php.ini並設置了display_errors = Ondisplay_startup_errors = On。 什麼都沒有發生。

+1

如何爲'display_errors'設置? – PeeHaa

+0

檢查display_errors設置 –

+0

沒有幫助,因爲我已在我的問題編輯中反映出來。 –

回答

45

你的文件有語法錯誤,所以你的文件沒有被解釋,所以設置沒有改變,你有空白頁面。

你可以將你的文件分成兩份。

的index.php

<?php 
ini_set("display_errors", "1"); 
error_reporting(E_ALL); 
include 'error.php'; 

error.php

<? 
echo('catch this -> ' ;. $thisdoesnotexist); 
+0

這個工作。 index.php顯示錯誤。但不管我做什麼,error.php仍然是一個空白的頁面。 –

8

該錯誤是解析錯誤解析器正在通過代碼拋出它,試圖理解它。 解析階段尚未執行任何代碼。由於它尚未執行error_reporting行,因此錯誤報告設置尚未更改。

您不能在具有語法錯誤的文件中更改錯誤報告設置(或者確實,請執行任何事情)。

9

在你的php.ini文件中檢查display_errors。我認爲它關閉了。

<?php 
error_reporting(E_ALL); 
ini_set('display_errors', TRUE); 
ini_set('display_startup_errors', TRUE); 
+0

我只是將它們都設置爲On。沒有變化。 –

+0

你不會內聯,他們需要在php ini文件中設置 – exussum