Disable PHP Warnings, Notices and Errors – WordPress
WordPress runs on PHP programming language. This means that whenever there is an error in the PHP scripts, the errors are reported to you.
However, this is not convenient because the errors appear on the website.
This means that even visitors may see these errors. In this guide, you will learn the circumstances that result in these warnings and how to fix them.
Definition of PHP Warnings, Notices and Errors
PHP issues are reported using three messages, i.e. warnings, notices, and errors. We will define them from the least critical to the most vital.
PHP Notices
According to the official PHP website, PHP notices occur when scripts encounter an event that could result in an error. However, it is important to note that this also happens to scripts running usually. Therefore, notices are the least important.
PHP Warnings
According to the PHP official website, PHP Warnings are non-fatal errors where the execution of the script is not halted. PHP warnings are moderately important; however, cannot break your site.
PHP Errors
PHP official website defines PHP errors as fatal run-time errors. These are errors that cannot be recovered from, e.g. memory allocation error. PHP errors result to scripts being halted and could potentially break your website.
Solution #1 Disable Error Reporting
Since most of these warnings and notices are not fatal, disabling error reporting is the best solution. You will need to access your website root files and edit the config file. You can use an FTP client or C-panel.
1. Get access to your website’s root folder. This guide will demonstrate how to utilize the C-panel. Log in to your C-panel dashboard and open the ‘File Manager’ as illustrated below.
2. Within your website root folder, open the ‘wp-config.php’ file as shown below.
3. Just above the “/* That’s all, stop editing! Happy Blogging. */” line, set the ‘WP_DEBUG’ value to true as shown below. Save the changes and check your website. All the errors should be gone.
Solution #2: Solve the error message that appears
In case the error is affecting the functionality of your website, it is advisable to research on the error and fix it. The PHP official website is a great resource to debug your errors.