Sophie

Sophie

distrib > Mandriva > 2008.1 > i586 > by-pkgid > 703d980c580707c382b4e43e25965bc5 > files > 2206

php-manual-pt_BR-5.2.4-1mdv2008.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>libxml_get_errors</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="Manual do PHP"
HREF="index.html"><LINK
REL="UP"
TITLE="libxml Functions"
HREF="ref.libxml.html"><LINK
REL="PREVIOUS"
TITLE="libxml_clear_errors"
HREF="function.libxml-clear-errors.html"><LINK
REL="NEXT"
TITLE="libxml_get_last_error"
HREF="function.libxml-get-last-error.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=UTF-8"></HEAD
><BODY
CLASS="refentry"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Manual do PHP</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.libxml-clear-errors.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.libxml-get-last-error.html"
ACCESSKEY="N"
>Próxima</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.libxml-get-errors"
></A
>libxml_get_errors</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN102832"
></A
><P
>    (PHP 5 &#62;= 5.1.0RC1)</P
>libxml_get_errors&nbsp;--&nbsp;
   Retrieve array of errors
  </DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN102835"
></A
><H2
>Descrição</H2
>array <B
CLASS="methodname"
>libxml_get_errors</B
> ( void  )<BR
></BR
><P
>&#13;   Retrieve array of errors.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN102842"
></A
><H2
>Valores de retornado</H2
><P
>&#13;   Returns an array with LibXMLError objects if there are any
   errors in the buffer, or an empty array otherwise.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN102846"
></A
><H2
>Exemplos</H2
><P
>&#13;   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN102849"
></A
><P
><B
>Exemplo 1. A <B
CLASS="function"
>libxml_get_errors()</B
> example</B
></P
><P
>&#13;     This example demonstrates how to build a simple libxml error handler.
    </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /><br />libxml_use_internal_errors</font><font color="#007700">(</font><font color="#0000BB">true</font><font color="#007700">);<br /><br /></font><font color="#0000BB">$xmlstr </font><font color="#007700">= &lt;&lt;&lt; XML<br /></font><font color="#0000BB">&lt;?xml version='1.0' standalone='yes'?&gt;<br />&lt;movies&gt;<br /> &lt;movie&gt;<br />&nbsp;&nbsp;&lt;titles&gt;PHP: Behind the Parser&lt;/title&gt;<br /> &lt;/movie&gt;<br />&lt;/movies&gt;<br /></font><font color="#007700">XML;<br /><br /></font><font color="#0000BB">$doc </font><font color="#007700">= </font><font color="#0000BB">simplexml_load_string</font><font color="#007700">(</font><font color="#0000BB">$xmlstr</font><font color="#007700">);<br /></font><font color="#0000BB">$xml </font><font color="#007700">= </font><font color="#0000BB">explode</font><font color="#007700">(</font><font color="#DD0000">"\n"</font><font color="#007700">, </font><font color="#0000BB">$xmlstr</font><font color="#007700">);<br /><br />if (!</font><font color="#0000BB">$doc</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$errors </font><font color="#007700">= </font><font color="#0000BB">libxml_get_errors</font><font color="#007700">();<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;foreach (</font><font color="#0000BB">$errors </font><font color="#007700">as </font><font color="#0000BB">$error</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#0000BB">display_xml_error</font><font color="#007700">(</font><font color="#0000BB">$error</font><font color="#007700">, </font><font color="#0000BB">$xml</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">libxml_clear_errors</font><font color="#007700">();<br />}<br /><br /><br />function </font><font color="#0000BB">display_xml_error</font><font color="#007700">(</font><font color="#0000BB">$error</font><font color="#007700">, </font><font color="#0000BB">$xml</font><font color="#007700">)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$return&nbsp;&nbsp;</font><font color="#007700">= </font><font color="#0000BB">$xml</font><font color="#007700">[</font><font color="#0000BB">$error</font><font color="#007700">-&gt;</font><font color="#0000BB">line </font><font color="#007700">- </font><font color="#0000BB">1</font><font color="#007700">] . </font><font color="#DD0000">"\n"</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$return </font><font color="#007700">.= </font><font color="#0000BB">str_repeat</font><font color="#007700">(</font><font color="#DD0000">'-'</font><font color="#007700">, </font><font color="#0000BB">$error</font><font color="#007700">-&gt;</font><font color="#0000BB">column</font><font color="#007700">) . </font><font color="#DD0000">"^\n"</font><font color="#007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;switch (</font><font color="#0000BB">$error</font><font color="#007700">-&gt;</font><font color="#0000BB">level</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case </font><font color="#0000BB">LIBXML_ERR_WARNING</font><font color="#007700">:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$return </font><font color="#007700">.= </font><font color="#DD0000">"Warning $error</font><font color="#007700">-&gt;</font><font color="#DD0000">code: "</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case </font><font color="#0000BB">LIBXML_ERR_ERROR</font><font color="#007700">:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$return </font><font color="#007700">.= </font><font color="#DD0000">"Error $error</font><font color="#007700">-&gt;</font><font color="#DD0000">code: "</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case </font><font color="#0000BB">LIBXML_ERR_FATAL</font><font color="#007700">:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$return </font><font color="#007700">.= </font><font color="#DD0000">"Fatal Error $error</font><font color="#007700">-&gt;</font><font color="#DD0000">code: "</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$return </font><font color="#007700">.= </font><font color="#0000BB">trim</font><font color="#007700">(</font><font color="#0000BB">$error</font><font color="#007700">-&gt;</font><font color="#0000BB">message</font><font color="#007700">) .<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">"</font><font color="#007700">\n</font><font color="#DD0000">&nbsp;&nbsp;Line: $error</font><font color="#007700">-&gt;</font><font color="#DD0000">line" </font><font color="#007700">.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">"</font><font color="#007700">\n</font><font color="#DD0000">&nbsp;&nbsp;Column: $error</font><font color="#007700">-&gt;</font><font color="#DD0000">column"</font><font color="#007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;if (</font><font color="#0000BB">$error</font><font color="#007700">-&gt;</font><font color="#0000BB">file</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$return </font><font color="#007700">.= </font><font color="#DD0000">"</font><font color="#007700">\n</font><font color="#DD0000">&nbsp;&nbsp;File: $error</font><font color="#007700">-&gt;</font><font color="#DD0000">file"</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;return </font><font color="#DD0000">"$return</font><font color="#007700">\n\n</font><font color="#DD0000">--------------------------------------------</font><font color="#007700">\n\n</font><font color="#DD0000">"</font><font color="#007700">;<br />}<br /><br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
>O exemplo acima irá imprimir:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>&#60;titles&#62;PHP: Behind the Parser&#60;/title&#62;
^
Fatal Error 76: Opening and ending tag mismatch: titles line 4 and title
  Line: 4
  Column: 0

--------------------------------------------</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN102856"
></A
><H2
>Veja também</H2
><P
>&#13;   <P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
><A
HREF="function.libxml-get-last-error.html"
><B
CLASS="function"
>libxml_get_last_error()</B
></A
></TD
></TR
><TR
><TD
><A
HREF="function.libxml-clear-errors.html"
><B
CLASS="function"
>libxml_clear_errors()</B
></A
></TD
></TR
></TBODY
></TABLE
><P
></P
>
  </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.libxml-clear-errors.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Principal</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.libxml-get-last-error.html"
ACCESSKEY="N"
>Próxima</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>libxml_clear_errors</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.libxml.html"
ACCESSKEY="U"
>Acima</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>libxml_get_last_error</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>