cPanel Hosting User Guides

How to enable and disable PHP error messages in cPanel

In this article, you will learn how to enable and disable PHP error messages using the display_errors directive in the php.ini file.

The steps in this article can be completed if you have already set up a custom php.ini file on your website.

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
You can use the phpinfo() function to check the current value of the display_errors directive and other directives.