PHP - Function error_get_last()


Advertisements


Syntax

array error_get_last ( void );

Definition and Usage

The function gets information about the last error that occured.

Parameters

ParameterDescription
voidNA.

Return Value

Returns an associative array describing the last error with keys "type", "message", "file" and "line". Returns NULL if there hasn't been an error yet.

Example

Following is the usage of this function:

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

This will produce following result:

Array
(
    [type] => 8
    [message] => Undefined variable: a
    [file] => /var/www/tutorialspoint/php/test.php
    [line] => 2
)

php_function_reference.htm