Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

error_get_last()

Example

Retrieve the most recent error that occurred.

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

Definition and Usage

The error_get_last() function returns the most recent error that occurred as an associative array. This array includes the following keys:

  • [type] – Specifies the type of error.
  • [message] – Contains the error message.
  • [file] – Indicates the file in which the error occurred.
  • [line] – Specifies the line number where the error occurred.

Syntax

error_get_last();

Technical Details

Return Value:

Returns an associative array containing the details of the last error, with keys: type, message, file, and line. Returns null if no error has occurred.

PHP Version:

5.2+