Lightroom 3 is out »

PHP display errors

PHP display_errors setting

There is a setting called "display_errors" in the php.ini (PHP configuration file) that controls whether PHP displays coding errors out to to browser or not. During development, it is good to have this turned on so that you can see your coding problems as it happens. However, in a live website, you should turn this off. For security, you do not want the error display to inadvertently display certain information (such as file paths) to potential hackers.

To see if this setting is on or off, you can put up a PHP page containing the phpinfo() call that will display the PHP setting to your browser. Definitely remove that page after use. You don't want potential hackers to see those settings.

How to Turn Off Display Errors

Put the line ...
display_errors = Off
in the php.ini file in the directory where you want display error to be off.

The change should happen immediately and reflected in the setting displayed using phpinfo() after you refresh your browser.

If it did not work, try ...
display_errors = "0"

or ...
display_errors = 0

Sometimes it might depend on what PHP version and server environment you are running on. Or it may be that your webhost has made the setting un-changable.

Note that on some web servers, you will need to put this php.ini setting to each sub-directories in order for it to take effect in those sub-directories.

How to Turn Display Errors On

To turn on PHP display errors, you can use ...
display_errors = On
display_errors = "1"
display_errors = 1

But if you want keep your display_errors setting turned off but display errors only in a particular script, you can follow the tutorial here.