How to hide PHP errors in WordPress?

One of the WordPress capabilities for developers is PHP errors. It allows you to see errors in your coding. Perhaps at a glance, it seems to be a good feature, but the problem here is that the errors are visible to website visitors and we do not want that to be the case. In this article, let’s teach you How to hide PHP errors in WordPress.

Why and when should we hide PHP errors in WordPress?

PHP errors that you can see on your website are often warnings and notifications. When you say error, you should not be the same with the internal server error or other fatal ones. Notices will not put your site in any way inaccessible or damaged. The main purpose of these alerts is to help programmers to resolve code issues. Developers need this information to match their code with different standards and browsers. You may see errors like the below image in the WordPress dashboard.

How to hide PHP errors in WordPress?

How to hide PHP errors in WordPress?

Even in some cases, PHP errors are also seen in the front end of your site.

How to hide PHP errors in WordPress?

If you see a warning like the image above on your site, it’s better to let your website developer know what to do. You can also stop the display of alerts.

Disable and hide PHP errors in WordPress

We need to change the wp-config.php file to stop the error display. After you open this file in the host manager, find the following code. you can reach the file with CPanel or FileZilla.

 define(‘WP_DEBUG’, true);

It’s likely that your site code value will be the false and see the code as follows.

define(‘WP_DEBUG’, false);

Whichever is the case above, you must delete it and place the following code instead.

ini_set(‘display_errors’,’Off’);

ini_set(‘error_reporting’, E_ALL );

define(‘WP_DEBUG’, false);

define(‘WP_DEBUG_DISPLAY’, false);

Do not forget to save it after making changes. Now you can go back to your website and see if the errors are no longer displayed.

Enable display of PHP errors in WordPress

If you decide to re-enable PHP errors for any reason, it’s easy to do. Just open the wp-config.php file again and replace the code in the previous section with the following code.

define(‘WP_DEBUG’, true);

define(‘WP_DEBUG_DISPLAY’, true);

Comment on How to hide PHP errors in WordPress if you know better method and make us feel better.

How to hide PHP errors in WordPress?
4.1 (82.5%) 16 votes

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *