PHP .user.ini

Just discovered a great new feature of PHP 5.3. .user.ini can override the main php.ini directives. Anything not classified as PHP_INI_SYSTEM in the List of php.ini directives can be set here and used locally.

I’ve found it very useful for error reporting. On my development sites, I want to be able to see all errors immediately – including those at NOTICE level which can get forgotten in a log file. However, this is not acceptable on a production site and my web hosting company, quite rightly, has the main php.ini display levels set to off, with all errors logged to the error log. So all I have to do in .user.ini is:

display_errors = On
display_startup_errors = On

I did think about setting them using the PHP function error_reporting(), however, this would still show the ‘white screen of death’ since the PHP script would have failed before error_reporting() was run.

Scroll to Top