Guest post

While running a WordPress-based website, you may have encountered various PHP errors. Most often, they will appear when updating the system, plugins and theme, when there is a conflict between different versions of extensions or a theme and WordPress. PHP error can also occur during manual modifications of files, changes in their content during hacks, insufficient operational memory, etc.

On pages dedicated to WordPress, you can find a list with at least 40 common PHP errors. However, not all of these errors necessarily cause a white "death" screen with a crash message (e.g. Figure 1). In this case, you need to make changes in the code of the website according to the recommendations of the system or change the configuration of the PHP engine itself, e.g. slightly increase the operating memory allocated to the PHP process.

website error

If the information in the communication does not allow you to quickly find the cause of the failure - restore the site from the last backup and try to calmly trace the cause of the problem. I hope you make a regular backup before each major update of your system, plugins or theme. For major changes it's also a good idea to make the modifications on a standalone copy first and test if everything is OK that way. If it is OK you can make the changes on the production version of the site.

If the problem is not critical (Notice or Warning), then depending on your local PHP configuration the administrator but also other users of your site may be alerted to it by a message that appears above the site header. And although such a solution is intended to help you catch the problem quickly and fix it, it is not very good from the point of view of other users of your site. Such a message can significantly reduce trust in you especially when it comes to an e-commerce or business-like site.

If a customer goes to a product page and sees an error, they will probably wonder whether it is worth ordering something here. Would you order? That's why it's best to disable the display of PHP error notifications. Then visitors won't see any messages bothering them. On the other hand, you have to be aware that you won't be able to see them yourself, so it's a good idea to check the error logs on the server from time to time.

Some notifications may appear in the WordPress admin panel (Figure 2), but this does not have to be the case at all.

error in the backend
Figure 2. Error message in WordPress admin panel

To disable the display of PHP error notifications on the page, you can modify the wp-config.php system. You will find it in the WordPress root folder. You can get to this file using the file manager in the hosting account panel or through a classic FTP client. In our case, we used the software available on the hosting (fig. 3)

file manager
Figure 3. file manager

Edit the selected configuration file and find the line with the code define('WP_DEBUG', true) and change the value of "true" to "false". However, it is likely that WP_DEBUG already has a value of "false", so just make sure it actually does. This does not guarantee that error notifications will be hidden though. So to block them from appearing on the page, it's worth adding a few more lines of code:

ini_set('display_errors','Off');
ini_set('error_reporting', E_ALL );
define('WP_DEBUG_DISPLAY', false);
wp-config
Figure 4. Editing the wp-config.php file

You can close the file after saving all changes. PHP error notifications will not be visible to users.

Another way which is much faster and does not interfere with the WP configuration file is to simply make a change to the PHP settings on the server. In the case of cPanel, all you need to do is go to the PHP configuration editor section:

PHP editor

Then select your domain and disable the display of PHP errors:

disable error display

Summary

The above solution hides the PHP error messages that appear above the page header from visitors. However, hiding these notifications is not a solution to the problem. Therefore, from time to time, it is a good idea to either re-enable the error display, or better yet, take a look at the error log file you find in your hosting account.

P.S. I hope the solution given will be useful. If you have any questions or comments, please write.

Share

See also

How much does an online shop cost

How much does an online shop cost

How much does an online shop cost? A question that is practically always asked as soon as we start thinking about the possibility of getting into e-commerce. However, it is worth breaking down

How to add an FTP account

How to add an FTP account

Each hosting service has a master FTP account with access privileges to all files on the service's disk. The access data of the main account are

Free information on JZS news

I invite you to become a subscriber! Thousands of readers already subscribe to news from JZS.

You can unsubscribe at any time. Your address is safe here.

Featured LifeTime Offers!

Play.ht lifetime
Play.ht

Turn your website publications into high quality audio recordings.

AppMySite

Create a native mobile app for your WooCommerce shop

Leave a Reply

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