libxml_get_errors
Description
The libxml_get_errors of libxml for PHP retrieves an array of errors.
Syntax
libxml_get_errors(): array
Return
Returns an array with LibXMLError objects if there are any errors in the buffer, or an empty array otherwise.
Value | Constant | Description |
---|---|---|
0 | LIBXML_ERR_NONE | No errors |
1 | LIBXML_ERR_WARNING | A simple warning |
2 | LIBXML_ERR_ERROR | A recoverable error |
3 | LIBXML_ERR_FATAL | A fatal error |
Examples
1 · void
<? $use_errors = true; libxml_use_internal_errors($use_errors); $data = <<<XML <?xml version="1."?> <books> <book> <titlex>title</title> </book> </books> XML; $simplexml_load_string = simplexml_load_string($data); if($simplexml_load_string === false) { $return = libxml_get_errors(); foreach($return as $value) { print_r($value); } } ?>
LibXMLError Object ( [level] => 1 [code] => 97 [column] => 19 [message] => Unsupported version '1.' [file] => [line] => 1 ) LibXMLError Object ( [level] => 3 [code] => 76 [column] => 24 [message] => Opening and ending tag mismatch: titlex line 4 and title [file] => [line] => 4 )