php8.5
Home/ Manual/ errorfunc / functions/ error_clear_last

error_clear_last

PHP function Edit on GitHub ✎

(PHP 7, PHP 8)

Clear the most recent error

Description

error_clear_last(): void

Parameters Parameters

Return Values

Clears the most recent errors, making it unable to be retrieved with error_get_last().

Examples

An error_clear_last() example

php
<?php
var_dump(error_get_last());
error_clear_last();
var_dump(error_get_last());

@$a = $b;

var_dump(error_get_last());
error_clear_last();
var_dump(error_get_last());
?>

The above example will output something similar to:

output
NULL
NULL
array(4) {
  ["type"]=>
  int(8)
  ["message"]=>
  string(21) "Undefined variable: b"
  ["file"]=>
  string(9) "%s"
  ["line"]=>
  int(6)
}
NULL

See Also

Source: reference/errorfunc/functions/error-clear-last.xml · from the official PHP manual (php/doc-en)