Get 30% off your WordPress Hosting with code WPSAVE10. Launch Faster. Save More!
  • 00 Days
  • 00 Hours
  • 00 Minutes
  • 00 Seconds

How to disable PHP error reporting – Enhance Hosting

In this guide, we will learn how to hide or suppress PHP errors and notices such as the common PHP deprecated warnings.

Disable PHP error reporting

  1. Open Websites in the left sidebar
  2. Select the website where you would like to change the document root
  3. Select Advanced from the top menu and select the domain
  4. Select Developer Tools
  5. Scroll to php.ini editor and click Add directive
  6. Enter the required error_reporting directive

en-php-errorreporting-1024x619.png

The PHP runtime configurations within your own code can override the above settings specified in php.ini. To identify where this occurs, search your PHP scripts for occurrences of ini_set or error_reporting.

Alternatively, consider downgrading your PHP version to one that does not deprecate the functions your code relies on. This could resolve the issue without needing to alter script configurations.

Error reporting usage

Here’s a list of directives you can modify:

error_reporting

This directive controls which errors and warnings should be reported. To disable error reporting entirely, you can set it to 0. However, it’s generally not recommended to disable error reporting completely in a production environment. For development purposes, you might want to set it to E_ALL & ~E_NOTICE to report all errors except notices.

error_reporting = 0

display_errors

This directive determines whether errors should be displayed to the user (in the browser) or not. Setting it to Off will prevent errors from being displayed.

display_errors = Off

log_errors

If you want to log errors to a file rather than displaying them, you can set this directive to On. This can be useful for debugging purposes without exposing errors to users.

log_errors = On

error_log

This directive specifies the file where PHP errors should be logged when log_errors is enabled. You can specify a file path here.

error_log = /path/to/error.log

Error reporting bitmasks

E_ALL

Report all PHP errors and warnings.

error_reporting = E_ALL

E_ERROR

Report only fatal errors that halt script execution.

error_reporting = E_ERROR

E_WARNING

Report runtime warnings (non-fatal errors).

error_reporting = E_WARNING

E_NOTICE

Report runtime notices.

error_reporting = E_NOTICE

E_PARSE

Report parse errors (syntax errors).

error_reporting = E_PARSE

E_DEPRECATED

Report usage of deprecated PHP features.

error_reporting = E_DEPRECATED

E_STRICT

Report recommendations to improve code compatibility.

error_reporting = E_STRICT

Combining bitmasks

You can combine these error levels using the bitwise AND (&) and the bitwise OR (|) operators, as well as the placement of the negation (~) operators.

For example, to report all errors except notices and strict standards:

error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to manage DNS – Enhance Hosting

How to add or edit DNS To add or edit DNS entries: Open Websites in the left sidebar Select...

Add a Staging Site & Push Live – Enhance Hosting

To add a staging website Open Websites in the left sidebar Click Add new Select either Start...

Importing a cPanel backup – Enhance Hosting

The cPanel importer allows you to migrate a cPanel account into your website. To import a...

How to manage FTP accounts – Enhance Hosting

To add an FTP accounts on a single website: On the website dashboard select the advanced...

How to enable Redis – Enhance Hosting

Redis can be enabled on a per-website basis. This setting is disabled by default. Once enabled...