(PHP 5 >= 5.1.0, PHP 7)
libxml_get_errors — Hataları içeren bir dizi döndürür
Hataları içeren bir dizi döndürür.
Tamponda bir hata oluşmuşsa LibXMLError nesnelerinden oluşan bir dizi, yoksa boş bir dizi döner.
Örnek 1 - libxml_get_errors() örneği
Örnekte basit bir libxml hata eylemcisinin gerçeklenişi gösterilmiştir.
<?php
libxml_use_internal_errors(true);
$xmlstr = <<< XML
<?xml version='1.0' standalone='yes'?>
<movies>
 <movie>
  <titles>PHP: Behind the Parser</title>
 </movie>
</movies>
XML;
$doc = simplexml_load_string($xmlstr);
$xml = explode("\n", $xmlstr);
if (!$doc) {
    $errors = libxml_get_errors();
    foreach ($errors as $error) {
        echo display_xml_error($error, $xml);
    }
    libxml_clear_errors();
}
function display_xml_error($error, $xml)
{
    $return  = $xml[$error->line - 1] . "\n";
    $return .= str_repeat('-', $error->column) . "^\n";
    switch ($error->level) {
        case LIBXML_ERR_WARNING:
            $return .= "Uyarı $error->code: ";
            break;
         case LIBXML_ERR_ERROR:
            $return .= "Hata $error->code: ";
            break;
        case LIBXML_ERR_FATAL:
            $return .= "Ölümcül hata $error->code: ";
            break;
    }
    $return .= trim($error->message) .
               "\n  Satır: $error->line" .
               "\n  Sütun: $error->column";
    if ($error->file) {
        $return .= "\n  Dosya: $error->file";
    }
    return "$return\n\n--------------------------------------------\n\n";
}
?>
Yukarıdaki örneğin çıktısı:
<titles>PHP: Behind the Parser</title> ----------------------------------------------^ Ölümcül hata 76: Opening and ending tag mismatch: titles line 4 and title Satır: 4 Sütun: 46 --------------------------------------------