Tag Archives: file manager

How to Fine-Tune PHP Error Reporting: Complete Disabling and Selective Controls Explained

This article explains how to turn off PHP error messages completely or tweak them to suit your needs.

PHP errors are generated by your websites and logged in error_log files in the directory where your PHP files are located. If you do not need the error_log file you can disable PHP error logging.

To turn off PHP error reporting, you need to add the following line to your .htaccess file to suppress any PHP error messages.

php_flag display_errors off

Quick Steps:

  1. Go to your cPanel account and select File Manager.
  2. Click on Settings, check the box Show hidden files and click Save.
  3. Open the .htaccess file and add the code “php_flag display_errors off”.
  4. Click on Save Changes to save and close the file.

Login into your cPanel account and open File Manager from the Files section.

cPanel home page.

cPanel home page.

Click on Settings in File Manager.

Settings in File Manager.

Settings in File Manager.

Tick the check box “Show hidden files” and click Save.

Settings in File Manager

Select your .htaccess file and click on the Edit option from the dashboard above.

Editing the .htaccess file.

Add the code “php_flag display_errors off” and click Save Changes.

Advanced options

Suppose you don’t want to disable PHP error reporting completely but to log only some specific types of PHP errors. In that case, you can add the following values in the .htaccess file alongside the value “php_flag display_errors on”

To report all types of errors and warnings: E_ALL

php_flag display_errors on
php_value error_reporting E_ALL

It’s the highest level, including notices, warnings, errors, strict standards, and deprecated functions.

To report only fatal errors: E_ERROR

php_flag display_errors on
php_value error_reporting E_ERROR

It does not include warnings, notices, or other non-fatal errors.

To report only warnings: E_WARNING

php_flag display_errors on
php_value error_reporting E_WARNING

It reports only warnings about potential issues that might cause problems but do not stop script execution.

To report only notices: E_NOTICE

php_flag display_errors on
php_value error_reporting E_NOTICE

Reports notice about non-critical issues, such as variable initialization, etc.

To report parse errors only: E_PARSE

php_flag display_errors on
php_value error_reporting E_PARSE

Reports parse errors that occur during PHP script compilation.

To report usage of deprecated functions only:

php_flag display_errors on
php_value error_reporting E_DEPRECATED

Reports usage of deprecated functions or features that might be removed in future PHP versions.

To report coding standards recommendations only:

php_flag display_errors on
php_value error_reporting E_STRICT

Reports coding standards recommendations to ensure compatibility with future versions of PHP.

Numeric Values (Bitwise OR combinations):

You can combine error constants using the bitwise OR operator (|) to report multiple types of errors. For example:

To report all errors except notices:

php_flag display_errors on
php_value error_reporting E_ALL & ~E_NOTICE

To report fatal errors and warnings but not notices:

php_flag display_errors on
php_value error_reporting E_ERROR | E_WARNING

Conclusion

Congrats! Now, you’ve successfully learned about how to disable or partially disable PHP error reporting using the .htaccess file.

How to Check Your Website’s Error Log in cPanel

If your website is not functioning or there is an error the first thing to check is the error log. cPanel comes with a built-in error log section that allows you to see the errors. In this document, we will discuss how to diagnose your website so you correct the problems.

You can check your website for errors in the cPanel interface or from the cPanel File Manager. First we will discuss how to check the errors via the cPanel interface.

Viewing Errors in the cPanel Interface

From the cPanel interface you can only see the last 300 errors your website logged. This can be very useful for finding broken links (404 errors) etc.

  1. Log in to your cPanel account and navigate to Metrics > Errors.
    The cPanel Metrics Page.

    The cPanel Metrics Page.

  2. You will see a box here and it will have the last 300 errors of the website.
The most recent error logs from your website.

The most recent error logs from your website.

Viewing Errors in the cPanel File Manager

You can see all the errors your website is generating using the cPanel File Manager tool.

  1. Login to cPanel.
  2. Click on the File Manager under Files.
  3. Move to the public_html folder, then select and open the error_log file.
    The Apache error_log in cPanel File Manager.

    The Apache error_log in cPanel File Manager.

How to Read The Errors

Basically an error log has five fields: date and time when it happened, type of error, the visitors IP, the location of where the error is occurring and the domain it is referring to. For most cases these details are sufficient to determine what is wrong and when it first started occurring.

Date and Time logged          Type      Visitor IP Address
[Fri Jan 17 21:07:47 2019]   [error]   [client 192.168.0.32] 

Location of the Error
File does not exist: /home/userna5/public_html/400.shtml, 

Domain Referrer
referer: http://example.com/?m=200911

Conclusion

Great work! Now you know how to check and review your website’s error logs in case there’s an issue.