How to turn off PHP error in WordPress

How to turn off PHP error in WordPress

Do you want to turn off a PHP error in your WordPress website? PHP error is helpful for the developers to debug website errors and other issues. Developers can improve their website code by viewing the PHP error log. But it’s not a good practice to show the PHP error log to your users. So here in this article, we will guide you to turn off PHP errors in WordPress.

Why is it important to turn off PHP errors?

It is not a professional way to display your website error to your users. It will create a negative impact on your website. PHP errors are not similar to other common WordPress errors like server errors or syntax errors. This type of error won’t restrict your website to load or any other features. PHP errors are like some warnings or notices.

Mainly PHP errors showed up to help the developer or website owner to analyze their website code to debug for issues or improvements. If you are a WordPress plugin or theme developer then you need this error log for compatibility. But for the other users of your website, you should hide this error as it looks unprofessional and your users may be confused to see the error message.

When you see any error notice on your website frontend then you can contact the author of that plugin or theme about the issue. You can also turn off these error notices showing on your website.

Turn off PHP error in WordPress

To turn off displaying PHP errors you need to customize your wp-config.php file. Open up your wp-config.php and look for the following code.

define('WP_DEBUG', true);

You can also see the condition as false. In that case, the code should look like this –

define('WP_DEBUG', false);

You need to replace this code with the following ones.

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

Save the file and all your PHP error notices will be hidden from your website. When you need to see the error notice or message then you can easily enable it. Again open up the wp-config.php file and replace the code you just added with the following –

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

This code will turn on the PHP error and you will be able to show the errors and notice them.

Wrapping Up

Following the process, you will be able to turn off the PHP error in your WordPress website. You can see our other articles to learn How To Fix the “Failed To Load Resource” Error In WordPress

How to fix white text and missing button errors in the WordPress visual editor

Difference between the cover image and the featured image in WordPress

We hope this article will help you. If you liked this article, please like our Facebook page to stay connected.