Setting PHP error reporting from a vhost or .htaccess

Here on our dev servers, we turn PHP error reporting full on so we get to know of any issues with our code well before it hits production (where errors are turned off).

This does, however, cause problems with older legacy sites that generate reams of warning errors because the developers were slack and – say – didn’t declare all their variables. So, the obvious solution is to set the error reporting at the VirtualHost or .htaccess level.

Or is it? At the recent PHPWM meeting, I brought up my issue that whenever I set it to be:

php_value error_reporting E_ALL & ~E_NOTICES

which in php.ini will give you errors but not the notices, it was _definitely_ not working for me in the vhost. A possible solution offered was to use the integer value of the constant instead but we all couldn’t remember what that was.

A quick Google later and it seems that using the text constants doesn’t work in the vhost or .htaccess but the integer version DOES. So the definitive answer to “How do I turn on PHP errors but get it to ignore warnings in a vhost” is

php_value error_reporting 6135

Well, this works for me on php 5.2.3 anyway 🙂


2 responses to “Setting PHP error reporting from a vhost or .htaccess”

  1. The problem you had was becuse it should be E_NOTICE not E_NOTICES

    1. It does not seem like so. It works only if I set integer.

Leave a Reply

Your email address will not be published. Required fields are marked *