libxml_clear_errors
Description
The libxml_clear_errors of libxml for PHP clears the libxml error buffer.
Syntax
libxml_clear_errors(): void
Return
No value is returned.
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)
{
echo "before:\n";
$libxml_get_errors = libxml_get_errors();
foreach($libxml_get_errors as $value)
{
print_r($value);
}
libxml_clear_errors();
echo "after:\n";
$libxml_get_errors = libxml_get_errors();
foreach($libxml_get_errors as $value)
{
print_r($value);
}
}
before:
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
)
after: