Search code examples
phperror-reporting

error reporting on specific folders


is there a way to set error_reporting(E_ALL); for a specific directory rather than including it in each file?

I'd like to turn on error reporting for my beta.mysite.com


Solution

  • You can use a .htaccess file in Apache. Just add this line:

    php_value error_reporting 6143
    

    Or for old PHP versions:

    php_value error_reporting 2047
    

    Note that you can't use the contants (like E_ALL)

    From the manual:

    Note: PHP Constants outside of PHP

    Using PHP Constants outside of PHP, like in httpd.conf, will have no useful meaning so in such cases the integer values are required. And since error levels will be added over time, the maximum value (for E_ALL) will likely change. So in place of E_ALL consider using a larger value to cover all bit fields from now and well into the future, a numeric value like 2147483647.