VOOZH about

URL: https://www.geeksforgeeks.org/php/how-to-get-the-last-occurred-error-using-php/

⇱ How to get the last occurred error using PHP ? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to get the last occurred error using PHP ?

Last Updated : 27 Jan, 2021

It is very easy to get information about the last error that occurred in PHP using error_get_last() function. We can get very detailed information about the error such as, file and line number at which the error occurred.

Syntax: 

error_get_last();

Return value:

 (associative array | NULL)

The associative array returned above contains data as follows:

  • type : Type of error (error code)
  • message : Error Message
  • file : Path of file in which error occurred
  • line : Line number at error occurred in above file

PHP code:

Output:

Array ( 
 [type] => 8 
 [message] => Undefined variable: var 
 [file] => /home/nzH0BV/prog.php 
 [line] => 2 
)
8
Undefined variable: var
/home/nzH0BV/prog.php
2
Comment