When PHP changes are made on your site (usually from upgrading the PHP version), you may find that PHP throws errors and warnings. In the past, these would display on your website and you could turn them off using a phprc file.
DreamHost now disables all PHP warnings by default. This means you should never see them on your website when making changes to PHP.
Where can I view PHP errors and warnings?
Since these warnings have been turned off globally, you won't see them on your site. But you can still see all PHP errors and warnings in your error.log file.
How can I display the warnings on my site?
To display the warnings on your site, you just need to add the following line to your phprc file:
display_errors = on
If any PHP errors are thrown, they will now display on your site.
This is NOT recommended on a live website since visitors will see the errors. The better option is to specify which types of errors you'd like to log and enable PHP error logging as described below.
Controlling what type of errors display
PHP allows you to specify which type of errors you would like displayed, or to save to your PHP error log file. For example:
|error_reporting = E_ALL||Logs all errors and warnings|
|error_reporting = E_ERROR||Fatal errors that occur during PHP's initial startup.|
|error_reporting = E_WARNING||Run-time warnings (non-fatal errors). Execution of the script is not halted.|
|error_reporting = E_NOTICE||Logs runtime notices (usually bugs in your website code)|
A full list of options can be found here:
Additionally, you can exclude certain types of errors by using the bitwise operator ~. For example, this will show all errors except NOTICE and DEPRECATED warnings.
error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED
Once added to your phprc file, you can then enable your PHP error log.
This allows you to view the errors in your log file, instead of displaying them on your website.
Setting error reporting in your script
As mentioned above, the phprc file controls which errors are displayed. As such, the following lines will not function in your PHP script to display errors:
The only way to display errors is to edit your phprc file.