PHP Error Reporting

Hi there,

I’ve included:
<?php
ini_set(‘display_errors’,1);
error_reporting(E_ALL);
?>

… in my script at the top of the page, deliberately made a syntax mistake and I am getting the blank screen - no errors!!

I’ve also went into my php.ini file and noticed that in my error reporting:

error_reporting
; Default Value: E_ALL & ~E_NOTICE
; Development Value: E_ALL | E_STRICT
; Production Value: E_ALL & ~E_DEPRECATED

display_errors
; Default Value: On
; Development Value: On
; Production Value: Off

; track_errors
; Default Value: Off
; Development Value: On
; Production Value: Off

Not sure what is happening?

Regards
Volterony

I’ve went into my apache error log and all the errors are being reported there. However, how do I output the errors to the browser when I run the script? I thought this was done through php.ini?

The PHP script that you are using seems good:


ini_set('display_errors',1);
error_reporting(E_ALL);

And should work if they are really set on top of the script.

But the lines you have seen in the INI file are examples under the explanation area of the file. So you should look below those lines and which looks like:


error_reporting = E_ALL & ~E_STRICT
display_errors = On

The answer is here: http://us.php.net/manual/en/errorfunc.configuration.php#ini.display-errors

Although display_errors may be set at runtime (with ini_set()), it won’t have any affect if the script has fatal errors. This is because the desired runtime action does not get executed.

Because it’s a parse error, the script cannot be parsed meaning the lines changing the error reporting setting are never parsed. You’ll have to enable display_ errors in php.ini if you want to see parse errors in the browser.