PHP Errors and warnings can be turned off in several ways:

  • From hPanel
  • From WordPress configuration file
  • From .htaccess
  • From the PHP file of the specific page

Option 1 - If you are using WordPress

If you are using WordPress, in the File Manager open your public_html/wp-config.php file. Check if it has one of these lines:

define('WP_DEBUG', true);
define('WP_DEBUG', false);

If one of them is present, remove the line. Add the following code:

ini_set('display_errors','Off');
ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);

That's it, not PHP errors will not be displayed on your WordPress website 😊

Opotion 2 - .htaccess and PHP files

In your public_html/.htaccess file (create it, if it's missing in public_html) add this line:

php_flag display_errors off

After this PHP errors will not be displayed on the website.

Option 3 - .php files code

If you want to hide PHP errors from a single session/page of your website, and you know for which PHP page you wish to disable errors display, just add this line to that page's file:

error_reporting(0);

And errors will be hidden 😊

NOTES:

Did this answer your question?