w3resource

PHP error handling functions - error_get_last()

Introduction 

The error_get_last() function is used to get information about the last error occurred.

Version:

PHP 5

Syntax:

error_get_last (void)

Parameters:

None

Return Values:

Returns an associative array stating the last error.
Keys of the returned array are "type", "message", "file" and "line". If no errors took place, it returns NULL.

Example:

<?php
$_SESSION['website'] = "w3r";session_destroy();// this is for destroying session, but which one?echo $_SESSION['website']."
";print_r(error_get_last());?>

The following code displays this output :

w3r 
Array( [type] => 2 [message] => session_destroy()
  [function.session-destroy]: Trying to destroy uninitialized session [file] => C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\php\erro-get-last-example.php [line] => 3)

Previous: debug_print_backtrace()()
Next: error_log()



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/php/error-handling/php-error-handling-function-error_get_last.php