Ubuntu – PHP errors not being displayed

apache-2.2lampPHPUbuntu

I'm using PHP with Apache on Ubuntu 12.10. Errors are not being displayed to the browser for some reason and I can't figure it out.

I have the following in my php.ini file:

error_reporting = E_ALL & ~E_DEPRECATED
display_errors = On
display_startup_errors = On
log_errors = On

I am also positive that I have edited the correct ini file by verifying it with php_ini_loaded_file(). I can also verify that the values are correctly set by doing the following in my script:

echo ini_get("display_errors"); // Outputs 1
echo ini_get("display_startup_errors"); // Outputs 1
echo ini_get("log_errors"); // Outputs 1
echo ini_get("error_reporting"); // Outputs -1

I have tried what seems like every possible combination of these settings (and restarting Apache after each change) and it is just not outputting errors. I am also not using ini_set anywhere in the script. It is being set only from the ini file.

Any ideas why errors aren't being displayed?

Update:

It turns out it IS showing some errors, but not all of them.

echo 'hello''; // Shows syntax error
trigger_error("E_USER_WARNING", E_USER_WARNING); // shows error
trigger_error("E_USER_NOTICE", E_USER_NOTICE); // shows error
trigger_error("E_USER_ERROR", E_USER_ERROR); // Doesn't show error

Best Answer

It turns out the problem was a combination of PEBKAC and the Content-type header. When doing:

header('Content-Type: application/xhtml+xml; charset=UTF-8');

the browser then expects a valid XML document. When there are specific errors, it causes the document not to display in the browser at all even though content was sent. Viewing the page source shows that the error did, in fact, get successfully sent to the browser along with all the other code. My problem was that I assumed that nothing was getting echoed at all because all I saw was white.