In this article, you will learn how to enable and disable PHP error messages using the display_errors directive in the php.ini file.
Error messages and the display_errors directive
PHP displays error messages in the user’s web browser by default. And this is a very useful feature in the initial development and debugging of your website. But after the development of a website is completed, displaying error messages can be a security risk. Error messages may reveal information about your website, like path information and variables that should be kept secret.
The display_errors directive determines whether PHP will display error messages in users’ web browsers. To prevent PHP from displaying error messages, change the display_errors directive in the php.ini file using a text editor as follows:
display_errors = off
Modify the display_errors directive in the php.ini file to allow PHP to display error messages as follows:
display_errors = on
- To view a complete list of php.ini directives, please open http://www.php.net/manual/en/ini.list.php.
- To get more information about the display_errors directive, please open http://www.php.net/manual/en/errorfunc.configuration.php#ini.display-errors.