How to Conceal PHP Errors and Warnings on your website

October 26, 2023 / Web Hosting

Learn how to conceal PHP errors and warnings on your website with this tutorial. While PHP errors and warnings can assist in website troubleshooting, you might not require them at all times. Various methods can be employed to disable these warnings and errors.

Let us find some different ways to hide errors and warnings on website:

  1. Using .htaccess File-
    1. Choose the “File Manager” option and open “public_html/.htaccess” file.
    2. In the absence of the .htaccess file, you can create one. Add the following lines-
      php_flag display_errors off
    3. Then, click “Save”. This will ensure that PHP errors are no longer visible on your website.
  2. Using WordPress Configuration file-
    1. For WordPress-based websites; choose “File Manager” and access the public_html/wp-config.php file.
    2. Verify the presence of the following lines-
      define(‘WP_DEBUG’, true);
      define(‘WP_DEBUG’, false);
    3. If either line exists, delete it and replace it with the following code-
      ini_set(‘error_reporting’, E_ALL );
      define(‘WP_DEBUG’, false);
      define(‘WP_DEBUG_DISPLAY’, false);
    4. PHP errors will now be hidden from view on your WordPress website.
  3. Using .php file-
    1. To conceal PHP errors from a specific page of your website, choose “File Manager” and access the necessary page’s “.php” file.
    2. Add the below line-
    3. Save the modifications, and PHP errors will be hidden on this specific page.

That is it!

Spread the love