English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

PHP error_get_last() Function Usage and Example

PHP Error & Loggings Reference Manual

The error_get_last() function returns the last occurred error.

Syntax

array error_get_last ( void );

Definition and usage

This function returns the last occurred error in the form of an array. If no error occurs, it returns NULL.

Parameter

Serial numberParameters and descriptions
1

void

No parameters

Return value

It returns an associative array, and returns NULL if there is no error.

The returned error array includes 4 Keys and values:

  • [type] - Error type

  •  [message] - Error message

  • [file] - The file where the error occurred

  • [line] - The line where the error occurred

Online Example

Here is the usage of this error_get_last function-

<?php
   echo $b;
   print_r(error_get_last());
?>
Test and see‹/›

This will produce the following result-

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