views:

49

answers:

1

In this question the OP mentions PHP throwing a 500 error automatically when error_reporting is off, and XDebug changing that behaviour.

That got me curious, as I've never heard of PHP automatically emitting 500s before. According to various quotes and answers on SO and elsewhere, it seems to indeed be PHP's default behaviour to throw a 500 Internal Server Error header if display_errors is set to false.

However, I am unable to find anything official on this. The manual pages on display_errors and error_reporting say nothing.

Does anybody know a good source in the PHP docs that talks about this?

+3  A: 

Not sure, but this may have been added in PHP 5.2.4:

  • Changed error handler to send HTTP 500 instead of blank page on PHP errors. (Dmitry, Andrei Nigmatulin)

There is also this discussion on the internals list that might be related:

Quoting:

Current time most PHP instalations use setting 'display_error=0'. This setting hides errors from user but may send to him just a blank page.

The proposed patch sends HTTP 500 response on errors instead of blank pages. The pages that already wrote something are not affectd.

Any objections or additions?

and the proposed solution/patch seems to be shown here:

Gordon
Good catch, thanks! This seems to be it. Then it's a badly documented new feature, as it doesn't even seem to have a ticket.
Pekka
One should note (and notify the patch author) that strictly speaking a blank page is a blank page, status code regardless, because a page is in the body, while the response code is in the header. This is even more important considering the fact that most browsers do not notify the users of status codes. It is expected that the response body tells them of that.
amn