cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Go to solution
Resolver VI

How to Hide PHP warnings and errors in WordPress?

You may think it is a mistake to hide them, because if there is a warning or PHP error in your WordPress, would not it be better to show it in order to fix it?

 

But that would be in an ideal world in which we could always, we even needed to live without mistakes. But the reality is that there are many and of many types the warnings and errors of PHP that a WordPress can show, and they will not always be something vital, urgent to solve .

 

I am referring to notices of unnecessary functions, compatibility warnings and lots of possible PHP notices that we can get to see in a web created with WordPress .

 

If you ever encounter warnings or PHP errors that - in reality - do not negatively affect the security or functioning of your website , you can hide them.

 

DEBUG MODE

Little more to say about the WordPress debug mode, which I already explained in this article about what WP_DEBUG is and how to use it .

 

But we can use it to hide PHP errors and warnings, at least checking that it is not active, and for that the easiest thing is to add this line to your file wp-config.php:

define('WP_DEBUG', false);

 

WHAT IF THEY CONTINUE TO SHOW ERRORS DESPITE HAVING THE DEBUG MODE IN FALSE ?

It can happen, especially in cheap hostings that - by commercial strategy - force the display of PHP errors , to encourage users to acquire superior plans or additional services or go to know.

 

If this is your case, and despite having falsedebug mode, PHP errors are still displayed, replace the previous line with this one in your wp-config.php:

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

 

With these lines should not show any error or warning of PHP in WordPress.

 

I WOULD NOT DO IT

Mind you, to teach you how to do these things does not mean you should not be aware and responsible with the errors and warnings of PHP, and you should only hide them when you know for sure that you are not hiding an error or warning about a security or programming problem. serious that may compromise your website or those of your clients.

 

Zulfiqar Anees | Founder/CEO at FastTech Media, TechMag, TechKnowable, and ZulWeb | GoDaddy Pro.
1 ACCEPTED SOLUTION
Community Manager

Great post @Zulfiqar! Thanks for sharing this. I'm sure someone will find it helpful Man Very Happy

 

JesseW - GoDaddy | Community Manager | 24/7 support available at x.co/247support | Remember to choose a solution and give kudos.

View solution in original post

1 REPLY 1
Community Manager

Great post @Zulfiqar! Thanks for sharing this. I'm sure someone will find it helpful Man Very Happy

 

JesseW - GoDaddy | Community Manager | 24/7 support available at x.co/247support | Remember to choose a solution and give kudos.

View solution in original post