December 27, 2024
Display PHP errors with built in functions
By displaying PHP errors we can help ourself to debug our programs/code in better way. We can easily identify issues present in our code and improve work quality. We can display all errors or we can display fatal errors, warning errors or notice errors also.
Below is example to display all PHP errors
<?php
error_reporting(E_ALL); // Report all PHP errors
ini_set('display_errors', 1); // Display errors on the screen
?>
Below is example to display fatal PHP errors only
<?php
error_reporting(E_ERROR); // Report only fatal runtime errors
ini_set('display_errors', 1); // Display errors on the screen
?>
Below is example to display warning PHP errors only
<?php
error_reporting(E_WARNING); // Report only warnings
ini_set('display_errors', 1); // Display errors on the screen
?>
Below is example to display notice PHP errors only
<?php
error_reporting(E_NOTICE); // Report only notice errors
ini_set('display_errors', 1); // Display errors on the screen
?>