<HTML ><HEAD ><TITLE >error_reporting</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" HREF="index.html"><LINK REL="UP" TITLE="Error Handling and Logging Functions" HREF="ref.errorfunc.html"><LINK REL="PREVIOUS" TITLE="error_log" HREF="function.error-log.html"><LINK REL="NEXT" TITLE="restore_error_handler" HREF="function.restore-error-handler.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></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" >PHP Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.error-log.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.restore-error-handler.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.error-reporting" ></A >error_reporting</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN22953" ></A ><P > (PHP 3, PHP 4 )</P >error_reporting -- set which PHP errors are reported</DIV ><DIV CLASS="refsect1" ><A NAME="AEN22956" ></A ><H2 >Description</H2 >int <B CLASS="methodname" >error_reporting</B > ( [int level])<BR ></BR ><P > The <B CLASS="function" >error_reporting()</B > function sets the <A HREF="ref.errorfunc.html#ini.error-reporting" >error_reporting</A > directive at runtime. PHP has many levels of errors, using this function sets that level for the duration (runtime) of your script. </P ><P > <B CLASS="function" >error_reporting()</B > sets PHP's error reporting level, and returns the old level. The <TT CLASS="parameter" ><I >level</I ></TT > parameter takes on either a bitmask, or named constants. Using named constants is strongly encouraged to ensure compatibility for future versions. As error levels are added, the range of integers increases, so older integer-based error levels will not always behave as expected. </P ><P > Some example uses: </P ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN22972" ></A ><P ><B >Example 1. <B CLASS="function" >error_reporting()</B > examples</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" ><?php // Turn off all error reporting error_reporting(0); // Report simple running errors error_reporting (E_ERROR | E_WARNING | E_PARSE); // Reporting E_NOTICE can be good too (to report uninitialized // variables or catch variable name misspellings ...) error_reporting (E_ERROR | E_WARNING | E_PARSE | E_NOTICE); // Report all errors except E_NOTICE // This is the default value set in php.ini error_reporting (E_ALL ^ E_NOTICE); // Report all PHP errors (bitwise 63 may be used in PHP 3) error_reporting (E_ALL); // Same as error_reporting(E_ALL); ini_set ('error_reporting', E_ALL); ?></PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ><P > The available error level constants are listed below. The actual meanings of these error levels are described in the <A HREF="ref.errorfunc.html#errorfunc.constants" >predefined constants</A >. <DIV CLASS="table" ><A NAME="AEN22978" ></A ><P ><B >Table 1. <B CLASS="function" >error_reporting()</B > level constants and bit values</B ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><THEAD ><TR ><TH ALIGN="LEFT" VALIGN="MIDDLE" >value</TH ><TH ALIGN="LEFT" VALIGN="MIDDLE" >constant</TH ></TR ></THEAD ><TBODY ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >1</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > <A HREF="phpdevel-errors.html#internal.e-error" >E_ERROR</A > </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >2</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > <A HREF="phpdevel-errors.html#internal.e-warning" >E_WARNING</A > </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >4</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > <A HREF="phpdevel-errors.html#internal.e-parse" >E_PARSE</A > </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >8</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > <A HREF="phpdevel-errors.html#internal.e-notice" >E_NOTICE</A > </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >16</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > <A HREF="phpdevel-errors.html#internal.e-core-error" >E_CORE_ERROR</A > </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >32</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > <A HREF="phpdevel-errors.html#internal.e-core-warning" >E_CORE_WARNING</A > </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >64</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > <A HREF="phpdevel-errors.html#internal.e-compile-error" >E_COMPILE_ERROR</A > </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >128</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > <A HREF="phpdevel-errors.html#internal.e-compile-warning" >E_COMPILE_WARNING</A > </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >256</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > <A HREF="phpdevel-errors.html#internal.e-user-error" >E_USER_ERROR</A > </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >512</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > <A HREF="phpdevel-errors.html#internal.e-user-warning" >E_USER_WARNING</A > </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >1024</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > <A HREF="phpdevel-errors.html#internal.e-user-error" >E_USER_NOTICE</A > </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >2047</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > <A HREF="phpdevel-errors.html#internal.e-all" >E_ALL</A > </TD ></TR ></TBODY ></TABLE ></DIV > </P ><P > See also the <A HREF="ref.errorfunc.html#ini.display-errors" >display_errors</A > directive and <A HREF="function.ini-set.html" ><B CLASS="function" >ini_set()</B ></A >. </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.error-log.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.restore-error-handler.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >error_log</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.errorfunc.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >restore_error_handler</TD ></TR ></TABLE ></DIV ></BODY ></HTML >