In this article, you will learn how to get the last occurred error in PHP. The error_get_last() function returns the last error that occurred. The output is returned as an associative array which contains following four keys.
- type – Define the type of the error
- message – Define the error message
- file – Define the file in which the error occurred
- line – Define the line where the error occurred
what is the syntax of the ERROR_GET_LAST() function in php?
examples of the ERROR_GET_LAST() function
Example 1. In this example, we return the last error that occurred.
<?php echo $test; print_r(error_get_last()); ?>