Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

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.

ValueConstantDescription
0LIBXML_ERR_NONENo errors
1LIBXML_ERR_WARNINGA simple warning
2LIBXML_ERR_ERRORA recoverable error
3LIBXML_ERR_FATALA 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
)
HomeMenu