php error_clear_last() function and error_get_last() function

怪我咯
Release: 2023-03-13 11:58:01
Original
1923 people have browsed it

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());
?>
Copy after login

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
Copy after login

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());
?>
Copy after login

The output of the above routine is similar to:

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

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template