Computer >> Computer tutorials >  >> Programming >> PHP

libxml_get_errors() function in PHP


The libxml_get_errors() function gets the array of errors. It gets the errors from the libxml error buffer.

Syntax

libxml_get_errors()

Parameters

  • NA

Return

The libxml_get_errors() function returns an array of error objects, and an empty array if there are no errors in the libxml error buffer.

Example

The following is an example −

<?php
   var_dump(libxml_use_internal_errors(true));
   $mydoc = new DOMDocument;
   if (!$mydoc->load('new.xml')) {
      foreach (libxml_get_errors() as $error) {
         // handle the errors now
      }
      libxml_clear_errors();
   }
?>