How to display errors in PHP

Displaying Error Messages in PHP

This assumes you have already installed PHP on your computer. By default, most PHP installations will not display error messages in the browser. This is a security feature. However, during development it's a good idea to display error messages. To set up your environment to display errors:

1. Find the PHP configuration file php.ini on your system. (On the Mac it is: /usr/local/php5/lib/php.ini)

On Macintosh or Linux: $locate php.ini

2. Edit php.ini and search for the these lines (which will not be consecutive):

error_reporting = E_ALL
display_errors = Off

and change them to:

error_reporting = E_ALL & ~E_NOTICE | E_STRICT
display_errors = On

3. Restart Apache:

$ sudo apachectl restart