<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >Reporting 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="Extending PHP 3" HREF="phpdevel.html"><LINK REL="PREVIOUS" TITLE="Calling User Functions" HREF="calling-user-functions.html"><LINK REL="NEXT" TITLE="FAQ: Perguntas Mais Freqüentes" HREF="faq.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"></HEAD ><BODY CLASS="sect1" 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="calling-user-functions.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >Capítulo 48. Extending PHP 3</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="faq.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="sect1" ><H1 CLASS="sect1" ><A NAME="phpdevel-errors" >Reporting Errors</A ></H1 ><P > To report errors from an internal function, you should call the <B CLASS="function" >php3_error()</B > function. This takes at least two parameters -- the first is the level of the error, the second is the format string for the error message (as in a standard <A HREF="function.printf.html" ><B CLASS="function" >printf()</B ></A > call), and any following arguments are the parameters for the format string. The error levels are: </P ><DIV CLASS="sect2" ><H2 CLASS="sect2" ><A NAME="internal.e-notice" ><TT CLASS="constant" ><B >E_NOTICE</B ></TT ></A ></H2 ><P > Notices are not printed by default, and indicate that the script encountered something that could indicate an error, but could also happen in the normal course of running a script. For example, trying to access the value of a variable which has not been set, or calling <A HREF="function.stat.html" ><B CLASS="function" >stat()</B ></A > on a file that doesn't exist. </P ></DIV ><DIV CLASS="sect2" ><H2 CLASS="sect2" ><A NAME="internal.e-warning" ><TT CLASS="constant" ><B >E_WARNING</B ></TT ></A ></H2 ><P > Warnings are printed by default, but do not interrupt script execution. These indicate a problem that should have been trapped by the script before the call was made. For example, calling <A HREF="function.ereg.html" ><B CLASS="function" >ereg()</B ></A > with an invalid regular expression. </P ></DIV ><DIV CLASS="sect2" ><H2 CLASS="sect2" ><A NAME="internal.e-error" ><TT CLASS="constant" ><B >E_ERROR</B ></TT ></A ></H2 ><P > Errors are also printed by default, and execution of the script is halted after the function returns. These indicate errors that can not be recovered from, such as a memory allocation problem. </P ></DIV ><DIV CLASS="sect2" ><H2 CLASS="sect2" ><A NAME="internal.e-parse" ><TT CLASS="constant" ><B >E_PARSE</B ></TT ></A ></H2 ><P > Parse errors should only be generated by the parser. The code is listed here only for the sake of completeness. </P ></DIV ><DIV CLASS="sect2" ><H2 CLASS="sect2" ><A NAME="internal.e-core-error" ><TT CLASS="constant" ><B >E_CORE_ERROR</B ></TT ></A ></H2 ><P > This is like an <TT CLASS="constant" ><B >E_ERROR</B ></TT >, except it is generated by the core of PHP. Functions should not generate this type of error. </P ></DIV ><DIV CLASS="sect2" ><H2 CLASS="sect2" ><A NAME="internal.e-core-warning" ><TT CLASS="constant" ><B >E_CORE_WARNING</B ></TT ></A ></H2 ><P > This is like an <TT CLASS="constant" ><B >E_WARNING</B ></TT >, except it is generated by the core of PHP. Functions should not generate this type of error. </P ></DIV ><DIV CLASS="sect2" ><H2 CLASS="sect2" ><A NAME="internal.e-compile-error" ><TT CLASS="constant" ><B >E_COMPILE_ERROR</B ></TT ></A ></H2 ><P > This is like an <TT CLASS="constant" ><B >E_ERROR</B ></TT >, except it is generated by the Zend Scripting Engine. Functions should not generate this type of error. </P ></DIV ><DIV CLASS="sect2" ><H2 CLASS="sect2" ><A NAME="internal.e-compile-warning" ><TT CLASS="constant" ><B >E_COMPILE_WARNING</B ></TT ></A ></H2 ><P > This is like an <TT CLASS="constant" ><B >E_WARNING</B ></TT >, except it is generated by the Zend Scripting Engine. Functions should not generate this type of error. </P ></DIV ><DIV CLASS="sect2" ><H2 CLASS="sect2" ><A NAME="internal.e-user-error" ><TT CLASS="constant" ><B >E_USER_ERROR</B ></TT ></A ></H2 ><P > This is like an <TT CLASS="constant" ><B >E_ERROR</B ></TT >, except it is generated in PHP code by using the PHP function <A HREF="function.trigger-error.html" ><B CLASS="function" >trigger_error()</B ></A >. Functions should not generate this type of error. </P ></DIV ><DIV CLASS="sect2" ><H2 CLASS="sect2" ><A NAME="internal.e-user-warning" ><TT CLASS="constant" ><B >E_USER_WARNING</B ></TT ></A ></H2 ><P > This is like an <TT CLASS="constant" ><B >E_WARNING</B ></TT >, except it is generated by using the PHP function <A HREF="function.trigger-error.html" ><B CLASS="function" >trigger_error()</B ></A >. Functions should not generate this type of error. </P ></DIV ><DIV CLASS="sect2" ><H2 CLASS="sect2" ><A NAME="internal.e-user-notice" ><TT CLASS="constant" ><B >E_USER_NOTICE</B ></TT ></A ></H2 ><P > This is like an <TT CLASS="constant" ><B >E_NOTICE</B ></TT >, except it is generated by using the PHP function <A HREF="function.trigger-error.html" ><B CLASS="function" >trigger_error()</B ></A >. Functions should not generate this type of error. </P ></DIV ><DIV CLASS="sect2" ><H2 CLASS="sect2" ><A NAME="internal.e-all" ><TT CLASS="constant" ><B >E_ALL</B ></TT ></A ></H2 ><P > All of the above. Using this error_reporting level will show all error types. </P ></DIV ></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="calling-user-functions.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="faq.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Calling User Functions</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="phpdevel.html" ACCESSKEY="U" >Acima</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >FAQ: Perguntas Mais Freqüentes</TD ></TR ></TABLE ></DIV ></BODY ></HTML >