2

My server (Apache2, PHP5) returns a blank page with Header Code 500 whenever it comes across a simple parse error in PHP. For instance:

<?php functiondoesnotexist(); ?>

or

<?php echo 'with2semicolons';; ?>

Does not output one of those orange tables telling me what's wrong, the server simply bails.

I've checked the Apache error logs and it is indeed telling me the error (for instance Undefined function functiondoesnotexist()).

How can I stop this behaviour? My php.ini is (as far as I know) untouched.

hakre
  • 193,403
  • 52
  • 435
  • 836
Alfo
  • 4,801
  • 9
  • 38
  • 51
  • possible duplicate of [How to get useful error messages in PHP?](http://stackoverflow.com/questions/845021/how-to-get-useful-error-messages-in-php) – hakre Mar 04 '13 at 02:35
  • I think this question and answer is very helpful, and should not have been closed, because as the asker typed, the issue happens mostly with any PHP error and HTTP error 500, when the PHP is not configured to display error and such it seems even like an incorrect configuration of PHP, server or networking, which is not the case, but the PHP is the cause. The best put together from other similar questions, very to the point. – FantomX1 Jun 03 '20 at 10:38

2 Answers2

7

You can set these error variables in your php.ini file:

error_reporting = E_ALL | E_STRICT
display_errors = On

And/or override them at the start of your php scripts when needed:

ini_set('display_errors', 1);
error_reporting(E_ALL | E_STRICT);
Mark
  • 2,669
  • 2
  • 17
  • 13
  • extraordinary, this does help, and aside of error log shows errors or logs them elsewhere outside of apache error log if configured in the app – FantomX1 Jun 03 '20 at 10:12
4

Try adding the error reporting and display_errors per ini_set before, e.g.:

<?php 
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); 
ini_set('display_errors', '1')
?>

...

<?php functiondoesnotexist(); ?>
scessor
  • 15,995
  • 4
  • 43
  • 54