PHP errors, warnings, and notices have their use – to help you deduct what the problem is, obviously. Then, you’ll know exactly whether it was a wrong syntax, or you need to install a WordPress plugin or even delete an entire theme in WordPress and start anew. Two great examples of that are WordPress white screen of death and the “This site is experiencing technical difficulties” error. Now that you realize its importance, it’s also evident that you don’t need its help all the time. Luckily, there’s a way to enable or disable the feature at will. Here’s how to turn off PHP errors in WordPress.
What are PHP errors?
PHP errors are the errors generated by PHP during the execution of the PHP script. As we all know, WordPress is developed in PHP and there are a lot of PHP scripts required to be executed in order for its proper functioning.
During this process, because of various reasons, WordPress may run into PHP errors. These are usually used by invalid code present in your theme or plugins. Also, if you upgrade to a newer PHP version and the code in your themes and plugins is old, you may encounter PHP errors.
These errors can be extremely beneficial to track down the issues you are facing on your WordPress website. Just looking at the error itself, you will understand which part of your website is causing the issues, helping you to solve the problem much faster.
Why should you turn it off?
As already mentioned, PHP errors are just errors for debugging purposes. Then why should you disable it?
Once an error occurs, it will be displayed on your WordPress backend until that issue is fixed. Sometimes, these errors can even pop up on the frontend of your website, affecting the user experience. Apart from the user-experience aspect, it can be a major security issue displaying errors on the frontend.
Also, if you are already working on a fix for the error is just a warning which is going to be fixed in the upcoming theme or plugin updates, there is no problem in hiding it.
The easiest way to disable PHP errors
You’ll need to access your WordPress files via FTP. To do this, you have two options. Both yield identical results, so you’re free to choose.
- Download and install an FTP client software.
Then, use the login details provided by your hosting (hostname or IP address, password, port, protocol) to access the root folder.
- Log in to your cPanel on your hosting website.
Look for an option called FTP, File Manager, or Files.
Then, do this:
- Find your WordPress website’s root folder.
It might also be called www, public_html, or have your domain name.
- Find a file named wp-config.php.
- Find the Edit option somewhere in the cPanel or FTP client.
- The file will open like any other text file.
- Press Ctrl (Control) + F on your keyboard.
- Search for ‘wp-debug.’
- Since PHP errors are enabled, you should find a line like this:
Tip: You’ll know you’re in the right place because there will be a line /* That’s all, stop editing! Happy blogging. */ below.
- Simply change true to false, so that it looks like this:
- Find the Save or Save Changes option in your software or the cPanel and press it.
- Refresh your website’s homepage, or the page you noticed errors on.
- Fixed? Great job!
What if it doesn’t work?
If this didn’t fix the issue, do this.
- Go back to the same line.
- Then, highlight the line and replace it with this:
ini_set(‘error_reporting’, E_ALL );
- Once again, Save Changes.
- The PHP errors shouldn’t be there anymore.
That’s it! Making PHP errors disappear from WordPress wasn’t so hard, was it? If you need to enable them in the future, install a developer addon such as Query Monitor, for example.