Member-only story
How to Display All Errors in PHP Easily
2 min readNov 13, 2024
Using ini_set()
and error_reporting()
to Show PHP Errors
To reveal all errors in PHP, add these lines at the start of your PHP script:
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
These settings, applied via ini_set()
and error_reporting()
, instruct PHP to show all runtime and startup errors, as well as other warnings and notices.
Here’s a quick breakdown of each directive:
- display_errors: This directive decides whether PHP will display errors as part of the page output. Setting it to
1
enable visible error messages. - display_startup_errors: This setting controls whether errors during PHP’s startup phase are displayed. Setting it to
1
help identify any issues that may occur during initialization. - error_reporting(E_ALL): This command adjusts the error level, and using
E_ALL
tells PHP to report all types of errors, warnings, and notices.
Configuring php.ini to Show All Errors
You can also enable global error display by editing your php.ini
file. Here’s how:
- Locate
php.ini
: Open a terminal or command prompt, then runphp --ini
. This command will…