即使錯誤報告處於打開狀態,Google App Engine中的錯誤也會被抑制並且不會顯示給瀏覽器。通常顯示給瀏覽器的html會顯示在日誌文件中。如何在GAE中的Web瀏覽器中顯示php錯誤?
下面的代碼應該產生一個錯誤
<?php
error
phpinfo();
?>
當冰壺沒有內容被返回只是一個500響應代碼的頁面。
$ curl -i http://localhost/test.php
HTTP/1.1 500 Internal Server Error
Content-Type: text/html
Cache-Control: no-cache
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Content-Length: 0
Server: Development/2.0
Date: Fri, 02 Aug 2013 18:24:49 GMT
此應用程序的php.ini中有display_errors = On
和的phpinfo正確顯示從應用程序中調用時。
預期的行爲是這樣
$ php-cgi54 test.php
X-Powered-By: PHP/5.4.14
Content-type: text/html
<br />
<font size='1'><table class='xdebug-error xe-parse-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>(!)</span> Parse error: syntax error, unexpected 'phpinfo' (T_STRING) in /Users/example/test/test.php on line <i>3</i></th></tr>
</table></font>
不知道是否有可能在GAE項目,但爲什麼你要顯示的錯誤直接輸出,而不是下面的日誌?當前的行爲對於安全性更好,而使用日誌仍然可以相對容易地進行調試。 –
我可能會爲了生產而關閉它,但使用SDK開發環境進行本地開發會非常好。 –