Home > Backend Development > PHP Tutorial > error_get_last() function in PHP

error_get_last() function in PHP

WBOY
Release: 2023-08-27 09:22:01
forward
1485 people have browsed it

error_get_last() function in PHP

error_get_last() function gets the last error that occurred in the form of an associative array. The associative array contains four keys -

  • [type] - describes the error type

  • [message] - describes the error message

  • [file] - Describes the file where the error occurred p>

  • [line] - Describes the line where the error occurred

Syntax

error_get_last()
Copy after login

Parameters

  • NA

Return

error_get_last() function returns an associative array describing the keys "type", " message", "file" and "line". If an error has not occurred, NULL is returned.

Example

The following is an example -

Real-time demonstration

<?php
   echo $res;
   print_r(error_get_last());
?>
Copy after login

Output

The following is the output. Here we are showing error in associative array -

Array
(
   [type] => 8
   [message] => Undefined variable: res
   [file] => /home/cg/root/4127336/main.php
   [line] => 2
)
PHP Notice: Undefined variable: res in /home/cg/root/4127336/main.php on line 2
Copy after login

The above is the detailed content of error_get_last() function in PHP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template