PHP error_clear_last() Function Last Updated : 28 Mar, 2023 Comments Improve Suggest changes Like Article Like Report The error_clear_last() function is an inbuilt function in PHP that is utilized to remove the most recent error. Syntax: error_clear_last(): void Parameter: This function does not accept any parameters. Return Value: The most recent error will be cleared & making it impossible to retrieve that error by using the error_get_last() function by this function. Example 1: The following code demonstrates the error_clear_last() function. PHP <?php echo $age; $error = error_get_last(); var_dump($error); // Clear the last error error_clear_last(); // Check the last error again $error = error_get_last(); var_dump($error); ?> Output: array(4) { ["type"]=> int(2) ["message"]=> string(23) "Undefined variable $age" ["file"]=> string(51) "/home/dachman/Desktop/Articles/GFG/Method/index.php" ["line"]=> int(3) } NULL Example 2: The following code demonstrates the error_clear_last() function. PHP <?php function custom_error_handler($errno, $errstr, $errfile, $errline) { echo "Error: $errstr\n"; } set_error_handler("custom_error_handler"); // Generate an error echo $age; // Clear the last error error_clear_last(); // Generate another error echo $age; ?> Output: Error: Undefined variable $age Error: Undefined variable $age Reference: https://www.php.net/manual/en/function.error-clear-last.php Create Quiz Comment N neeraj3304 Follow 0 Improve N neeraj3304 Follow 0 Improve Article Tags : PHP PHP-function PHP-Error-Handling Explore BasicsPHP Syntax4 min readPHP Variables5 min readPHP | Functions6 min readPHP Loops4 min readArrayPHP Arrays5 min readPHP Associative Arrays4 min readMultidimensional arrays in PHP5 min readSorting Arrays in PHP4 min readOOPs & InterfacesPHP Classes2 min readPHP | Constructors and Destructors5 min readPHP Access Modifiers4 min readMultiple Inheritance in PHP4 min readMySQL DatabasePHP | MySQL Database Introduction4 min readPHP Database connection2 min readPHP | MySQL ( Creating Database )3 min readPHP | MySQL ( Creating Table )3 min readPHP AdvancePHP Superglobals6 min readPHP | Regular Expressions12 min readPHP Form Handling4 min readPHP File Handling4 min readPHP | Uploading File3 min readPHP Cookies9 min readPHP | Sessions7 min read Like