Home  >  Article  >  Backend Development  >  php error_clear_last() function and error_get_last() function

php error_clear_last() function and error_get_last() function

怪我咯
怪我咯Original
2017-07-10 14:25:021865browse

error_clear_last — Clear the latest error

error_clear_last() Example

<?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 output of the above routine is similar to:

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

error_get_last — Get the last error that occurred, it returns an associated array, describing the last error information, with the error's "type", "message", "file" and "line" as the keys of the array . If the error is caused by a PHP built-in function, "message" will start with the function name. Returns NULL if there are no errors yet.

error_get_last() Example

<?php
echo $a;
print_r(error_get_last());
?>

The output of the above routine is similar to:

Array
(
    [type] => 8
    [message] => Undefined variable: a
    [file] => C:\WWW\index.php
    [line] => 2
)

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

Statement:
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