web stats OS X Client Server » Blog Archive » Disabling Reporting of PHP Notices on OS X



Disabling Reporting of PHP Notices on OS X


PHP

I ran in to a problem today. I noticed that my logs were being filled with PHP Notices. I had hundreds of lines in my error log that looked like this:

PHP Notice reporting
[Mon Dec 4 05:25:49 2006] [error] PHP Notice: Constant
[Mon Dec 4 05:25:49 2006] [error] PHP Notice: Constant
[Mon Dec 4 05:25:49 2006] [error] PHP Notice: Constant
[Mon Dec 4 05:25:50 2006] [error] PHP Notice: Use of undefined constant

It turns out I had my PHP error reporting set too high. I needed to turn off the reporting of PHP notices in my PHP.ini file.

On OS X your PHP.ini can be located in a few different places, here a few of the common ones.

usr/local/php/lib/php.ini
private/etc/php.ini
usr/local/php5/lib/php.ini

Search for the line:

error_reporting = E_ALL

And change it to:

error_reporting = E_ALL & ~E_NOTICE

Now just restart apache and apache will stop reporting PHP notices.

to restart apache open the terminal (Applications -> Utilities - > Terminal)
OS X Terminal

and type:

sudo apachectl graceful

Hit enter and type your password when prompted.



Leave a Reply