How to make apache display “only” PHP errors

apache-2.2php.iniphp5

Trying without succes to make apache display on screen errors on our development server.
Basically I understand that my:

error_reporting  =  E_ERROR & E_RECOVERABLE_ERROR & E_STRICT

Has no effect over:

display_errors = On

As this will also insist in displaying all PHP notices as well. I was hoping that only the specified error level on the PHP ini would have effect over the display_errors directive but so far I have not managed to get it working.

Apache 2.2, PHP 5.3 on Ubuntu 9

Best Answer

You're trying to filter specific types of notices, correct? The PHP manual shows a couple ways of doing this.

First, you can allow which errors to be reported by specifying the type followed by a pipe character (|) for each specified type. Second, if your intention is to remove a specified type you can use the caret character (^) (or NOT operator).

If you only want simple errors and warnings reported:

<?php display_errors(E_ERROR | E_WARNING); ?>

If you want to report all errors, but leave out error notices:

<?php display_errors(E_ALL ^ E_NOTICE); ?>

The only objective of display_errors is for visual purposes only and save you trips to the log file. All errors are logged regardless in a special log file.