Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
share|improve this question
    
Are there actually errors occurring? –  Michael Hampton Nov 21 '12 at 4:39
    
@MichaelHampton yes. If I add trigger_error("Errormsg", E_USER_ERROR); I get absolutely no output. Not even if anything was previously echoed. Removing that line and it is fine. Same goes with syntax errors. –  Mike Nov 21 '12 at 4:41
    
have you check on the phpinfo for display_errors and error reporting ? –  chocripple Nov 21 '12 at 5:39
    
@Rikih. phpinfo() matches what I put above in ini_get. –  Mike Nov 21 '12 at 18:37
    
It's impossible for these to be different. Even if you do ini_set and change one of the values it also changes the value in phpinfo. –  Mike Nov 21 '12 at 18:49

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.