PHP error_clear_last() Function Last Updated : 28 Mar, 2023 Summarize Comments Improve Suggest changes Share 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 Comment More infoAdvertise with us Next Article PHP | DsVector clear() Function N neeraj3304 Follow Improve Article Tags : PHP PHP-function PHP-Error-Handling Similar Reads PHP error_get_last() Function The error_get_last() function is an inbuilt PHP function in PHP which is used to get the last error that occurred. Syntax: error_get_last(): ?arrayParameter: This function does not accept any parameters. Return Value: It returns an associate array that explains the last error with keys "type", "mess 1 min read PHP | date_get_last_errors() Function The date_get_last_errors() function is an inbuilt function in PHP which is used to returns the warnings and errors. This function parse a date/time string and returns an array of warnings and errors. Syntax: Procedural style: array date_get_last_errors( void ) Object oriented style: array DateTime:: 1 min read PHP | DsVector clear() Function The Ds\Vector::clear() function is an inbuilt function in PHP which is used to clear the vector elements by removing all the elements from the vector. Syntax: void public Ds\Vector::clear( void ) Parameters: This function does not accept any parameter. Return Value: This function does not return any 1 min read PHP | DsVector last() Function The Ds\Vector::last() function is an inbuilt function in PHP which is used to return the last element of the vector. Syntax: mixed public Ds\Vector::last( void ) Parameters: This function does not contain any parameter. Return Value: This function returns the value at the last index in the vector. B 1 min read PHP array_âkey_âlast() Function The array_âkey_âlast() function is an inbuilt function in PHP that is used to get the last key of an array. This function returns the last key without affecting the internal array pointer. Syntax: int|string|null array_âkey_âlast(array $array) Parameters: This function accepts single parameter $arra 1 min read PHP | DsSet clear() Function The Ds\Set::clear() function is an inbuilt function in PHP which is used to remove all values from the set. Syntax: void public Ds\Set::clear( void ) Parameters: This function does not accept any parameter. Return value: This function does not return any value. Below programs illustrate the Ds\Set:: 1 min read Like