In this guide you will learn how to hide or suppress PHP errors and notices (such as the common PHP “deprecated” warnings).
Disabling PHP error messages
- Log in at https://cp.vcloudhosting.eu
- Open Websites in the left sidebar
- Select the website for which you want to change the document root
- Choose Advanced in the top menu and select the domain
- Choose Developer tools
- Scroll to php.ini editor and click Add directive
- Enter the error_reporting directive you want
PHP runtime settings within your own code can override the settings above that are specified in php.ini. Search your PHP scripts for ini_set or error_reporting to see where this happens.
Alternatively, you can use a lower PHP version that does not mark the functions your code depends on as deprecated. This can sometimes solve the problem without changing any scripts.
Using error reporting
Here is an overview of directives you can adjust:
- error_reporting: determines which errors and warnings should be reported. Set it to 0 to disable everything, but this is not recommended in production. For development you can use E_ALL & ~E_NOTICE, for example.
- display_errors: determines whether errors are shown to the user (in the browser). Set it to Off to hide errors.
- log_errors: if you want to log errors instead of displaying them, set this to On.
- error_log: here you can specify a path to a log file for logging errors.
Bitmasks for error reporting
- E_ALL: reports all PHP errors and warnings.
- E_ERROR: reports fatal errors only.
- E_WARNING: reports runtime warnings (non-fatal).
- E_NOTICE: reports runtime notices.
- E_PARSE: reports (syntax) errors during parsing.
- E_DEPRECATED: reports deprecated functions.
- E_STRICT: gives recommendations for better code compatibility.
You can combine these error levels with bitwise AND (&), OR (|) and NOT (~).
Example: to show all errors except notices and strict standards:
error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT