开发者

How do I get PHP to display Apache's 500 error page when it encounters an error, instead of a blank page?

I have apache directives set up for custom error docs for 404, 403, etc, as well as 500. However, PHP, upon encountering a fatal error, displays a blank page instead of triggering the apache 500 response.

I don't need to display the error de开发者_运维知识库tails or anything like that, as they are currently logged correctly in apache error_logs, so I don't think it has anything to do with error_reporting or display_errors, both of which are set correctly.

There are some similar questions here on SO, but haven't found an answer that does what I need. Basically, in the case of something like a syntax error, I want to see the apache 500 error page, NOT a blank page. This is not something that can be caught and handled in PHP, since syntax errors are uncatchable.

This appears to have been patched/fixed in php 5.2.4, as seen here: http://www.mail-archive.com/internals@lists.php.net/msg28557.html

However, we are using PHP 5.2.17, and an upgrade is not feasible at this time. Does anyone have any solutions / workarounds that might work to trigger 500 errors in apache for any PHP syntax/fatal error?


Not sure if this works: register a shutdown handler and display the appropriate page. The shutdown handler should get called whenever a fatal error occurs. Make sure that you register the handler on top of your script.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜