PHP error_get_last()Function


PHP Error 参考手册Complete PHP Error Reference Manual

Definition and Usage

The error_get_last() function obtains the last error that occurred.

This function returns the last error that occurred as an array. If no error occurs, it returns NULL.

The returned error array contains 4 keys and values:

  • [type] - Error type
  • [message] - Error message
  • [file] - File where the error occurred
  • [line] - Line where the error occurred

Syntax

error_get_last()


Examples

<?php
echo $test;
print_r(error_get_last());
?>

The output of the above code is shown below:

Array
(
[type] => 8
[message] => Undefined variable: test
[file] => C:webfoldertest.php
[line] => 2
)


PHP Error 参考手册Complete PHP Error Reference Manual Other Extensions