Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP emitting 500 on errors - where is this documented?

Tags:

php

apache

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?

like image 516
Pekka Avatar asked Jun 19 '10 11:06

Pekka


1 Answers

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:

  • [PHP-DEV] FW: php fastcgi

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:

like image 62
Gordon Avatar answered Sep 25 '22 14:09

Gordon