error_get_last() function gets the last error that occurred in the form of an associative array. The associative array contains four keys -
[type] - describes the error type
[message] - describes the error message
[file] - Describes the file where the error occurred p>
[line] - Describes the line where the error occurred
error_get_last()
error_get_last() function returns an associative array describing the keys "type", " message", "file" and "line". If an error has not occurred, NULL is returned.
The following is an example -
Real-time demonstration
<?php echo $res; print_r(error_get_last()); ?>
The following is the output. Here we are showing error in associative array -
Array ( [type] => 8 [message] => Undefined variable: res [file] => /home/cg/root/4127336/main.php [line] => 2 ) PHP Notice: Undefined variable: res in /home/cg/root/4127336/main.php on line 2
The above is the detailed content of error_get_last() function in PHP. For more information, please follow other related articles on the PHP Chinese website!