2017-03-31 92 views
-1

我在Vagrant(Ubuntu 16.04,Apache2,PHP7)中設置了一個LAMP堆棧,並且PHP沒有顯示任何錯誤。我有以下文件應該返回錯誤:在php.ini中,即使使用display_errors = On也沒有錯誤

This is a PHP File 
<?php thisisnotafunction(); ?> 
<?php echo date("ThisIsAnInvalidArgument"); ?> 

其他堆棧溢出的職位(post 1post 2post 3)的狀態,我需要改變php.ini文件中顯示錯誤。

運行$ sudo find/-name php.ini回報:

/etc/php/7.0/apache2/php.ini 
/etc/php/7.0/cgi/php.ini 
/etc/php/7.0/cli/php.ini 

我走進那些中的每一個,並設置display_errors = On,重新啓動的Apache2,但仍沒有任何錯誤。然而,增加後續到我的index.php文件確實顯示錯誤:

<?php 
    error_reporting(E_ALL); 
    ini_set("display_errors", 1); 
    require_once("sample.php"); 
?> 

的index.php現在返回:

This is a PHP File 
Warning: require_once(sample.php): failed to open stream: No such file or directory in /var/www/html/index.php on line 6 

Fatal error: require_once(): Failed opening required 'sample.php' (include_path='.:/usr/share/php') in /var/www/html/index.php on line 6 

所以很明顯我的PHP安裝知道如何處理錯誤。

+0

Apache指令可以設置或取消設置此標誌,ini可能不是您安裝使用的那個(也不一定要調用php.ini,php7可以讀取inis等的目錄等) – pvg

回答

0

使用php --ini命令將顯示您使用配置文件。

+1

This確認PHP正在使用哪個ini文件。謝謝。另外,對於其他尋找答案的人來說,事實證明'display_errors'在php.ini中顯示了**三次**(通常兩次,一次作爲註釋)。 – mohnjatthews

相關問題