Tags
Asked 2 years ago
9 Jun 2021
Views 180
shyam

shyam posted

How do I turn off PHP Notices?

How do I turn off PHP Notices?
web-api

web-api
answered Apr 25 '23 00:00

To turn off PHP notices, you can set the error_reporting level in your PHP code or in the php.ini configuration file. Here are the steps to do it:

1.To turn off PHP notices for the entire website, locate the php.ini configuration file in your server. You can use the phpinfo() function to find the location of the php.ini file.

2.Once you find the php.ini file, open it in a text editor and find the following line:



error_reporting = E_ALL

3.To turn off notices, change the value of error_reporting to the following:



error_reporting = E_ALL & ~E_NOTICE

This setting will still display warnings, errors, and fatal errors, but it will not display notices.

4.Save the php.ini file and restart your web server.

If you want to turn off notices for a specific page, you can add the following code at the beginning of your PHP code:


error_reporting(E_ALL & ~E_NOTICE);
ini_set('display_errors', '0');

This code will turn off notices for that page only.
Post Answer