PHP error_get_last() Function
Example
Returns the last error that occurred:
<?php echo $test; print_r(error_get_last()); ?>
The output of the above code is similar to this:
Array ( [type] => 8 [message] => Undefined variable: test [file] => C:\webfolder\test.php [line] => 2 )
Definition and Usage
The error_get_last() function returns 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
- [line] - Describes the line number where the error occurred
Syntax
error_get_last();
Technical Details
Return Value: |
Returns an associative array describing the last error information, with the keys being the error's "type", "message", "file", and "line". If the error is caused by a PHP built-in function, the "message" will start with the name of that function. Returns NULL if no error has occurred. |
---|---|
PHP Version: | 5.2+ |