How to display all errors in PHP

Overview

We use the E^ALL in the error_reporting PHP method to detect all possible errors in our code for debugging purposes.

The E^ALL is used inside the error_reporting method to display all errors in a code. We should use it just before deploying our code to production as it exposes vital details about our code.

Coding example

Let's look at the code below:

<?php
trigger_error("user warning!", E_USER_WARNING);
error_reporting(E_ALL);
?>

Code explanation

Line 2: We intentionally trigger an error.

Line 3: We allow the error to display using the error_reporting(E^ALL).

Note: Check out the shot on how to turn off error_reporting.

Free Resources