如果在寫php時忘記加分號( Semicolon ),訪問下面這個頁面會得到空白頁
1 2 3 | ini_set ( "display_errors" , "1" ); error_reporting (E_ALL); $bear = array (1,2,3) |
error_setting.php
1 2 3 | ini_set ( "display_errors" , "1" ); error_reporting (E_ALL); include 'error.php' ; |
1 2 | $bear = array (1,2,3) echo "test" ; |
Parse error: syntax error, unexpected 'echo' (T_ECHO) in /var/www/html/test.vm/error.php on line
但直接訪問error.php仍然會得到空白頁
20160519 找到原因
修改 /etc/php5/fpm/php.ini
error_reporting = E_ALL
error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT #忽略notice和Strict Standards錯誤,但會報Fatal錯誤
syntax和fatal 的error log 與 /etc/php5/fpm/php-fpm.conf 無關,與nginx /etc/nginx/sites-available/test.vm 的 error_log /var/www/html/test.vm/logs/error.log; 有關
這樣畫面上和error log 都有錯誤出現
http://stackoverflow.com/questions/1911920/does-php-error-reporting0-affect-error-logging-or-just-display
結論:看來沒辦法只顯fatal和syntax和notice示錯誤在error log,除非用error_log()或用框架做
參考資料:
http://stackoverflow.com/questions/16933606/error-reportinge-all-does-not-produce-error error_reporting(E_ALL) does not produce error
沒有留言:
張貼留言