|
|
|
Description
Description
</H2
><DIV
CLASS="funcsynopsis"
><A
NAME="AEN11687"
></A
><P
></P
><P
><CODE
><CODE
CLASS="FUNCDEF"
>int <B
CLASS="function"
>error_reporting</B
></CODE
> ([int
level])</CODE
></P
><P
></P
></DIV
><P
> Sets PHP's error reporting level and returns the old level. The
error reporting level is either a bitmask, or named constant. 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.
<TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN11695"
></A
><P
><B
>Example 1. Error Integer changes</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
> error_reporting (55); // PHP 3 equivalent to E_ALL ^ E_NOTICE
/* ...in PHP 4, '55' would mean (E_ERROR | E_WARNING | E_PARSE |
E_CORE_ERROR | E_CORE_WARNING) */
error_reporting (2039); // PHP 4 equivalent to E_ALL ^ E_NOTICE
error_reporting (E_ALL ^ E_NOTICE); // The same in both PHP 3 and 4
</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
Follow the links for the internal values to get their meanings:
<DIV
CLASS="table"
><A
NAME="AEN11698"
></A
><P
><B
>Table 1. <B
CLASS="function"
>error_reporting()</B
> bit values</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><THEAD
><TR
><TH
ALIGN="LEFT"
VALIGN="MIDDLE"
>constant</TH
><TH
ALIGN="LEFT"
VALIGN="MIDDLE"
>value</TH
></TR
></THEAD
><TBODY
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>1</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
> <A
HREF=devel-errors#internal.e-error"
>E_ERROR</A
>
</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>2</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
> <A
HREF=devel-errors#internal.e-warning"
>E_WARNING</A
>
</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>4</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
> <A
HREF=devel-errors#internal.e-parse"
>E_PARSE</A
>
</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>8</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
> <A
HREF=devel-errors#internal.e-notice"
>E_NOTICE</A
>
</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>16</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
> <A
HREF=devel-errors#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=devel-errors#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=devel-errors#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=devel-errors#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=devel-errors#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=devel-errors#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=devel-errors#internal.e-user-error"
>E_USER_NOTICE</A
>
</TD
></TR
></TBODY
></TABLE
></DIV
>
</P
><P
> <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN11752"
></A
><P
><B
>Example 2. <B
CLASS="function"
>error_reporting()</B
> examples</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
> error_reporting(0);
/* Turn off all reporting */
error_reporting (7); // Old syntax, PHP 2/3
error_reporting (E_ERROR | E_WARNING | E_PARSE); // New syntax for PHP 3/4
/* Good to use for simple running errors */
error_reporting (15); // Old syntax, PHP 2/3
error_reporting (E_ERROR | E_WARNING | E_PARSE | E_NOTICE); // New syntax for PHP 3/4
/* good for code authoring to report uninitialized or (possibly mis-spelled) variables */
error_reporting (63); // Old syntax, PHP 2/3
error_reporting (E_ALL); // New syntax for PHP 3/4
/* report all PHP errors */
</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
</P
></DIV
>
|
|
| DB Connection Function with error handling and email failure notices Categories : PHP, MySQL, Errors and Logging, Databases, Errors and Logging | | | A simple function to prevent undefined $_POST/$_GET/$_SESSION variable errors Categories : PHP, Variables, Errors and Logging | | | Logging 404 errors in your custom statistics using Apache and a PHP script. Categories : Apache, Web Servers, PHP, Errors and Logging | | | Visits-tracking Categories : PHP, Databases, MySQL, Errors and Logging, Functions | | | Error mailing logging facility Categories : PHP, Errors and Logging, Email | | | Ping a Server and run a command to fix it if it is down Categories : PHP, Errors and Logging, Regexps | | | A Custom Error Handling And Debugging Class Categories : PHP, PHP Classes, Debugging, Errors and Logging | | | Building a basic error handler with custom error types Categories : PHP, PHP Classes, Errors and Logging | | | Query2Report : Generating Html, Pdf and Csv Reports from SQL Query Categories : PHP, PHP, HTML, PDF, Excel | | | Example of function to send out email if error occurs Categories : PHP, Email, Debugging, Errors and Logging | | | [PHP5] PHP Debugger and Helper Categories : PHP, PHP Classes, Errors and Logging, Debugging, XML | | | error_log -- send an error message somewhere Categories : PHP, PHP Functions, Errors and Logging | | | Intelligent 404 Handler Categories : PHP, Errors and Logging | | | Retrieve text from table and email to your e-
address in pipe delimited format. Categories : PHP, MySQL | | | Accepts a database & hostname from a user and then HTTP username and password. Uses this to connect to a MySQL database. Produces a form based on the tables it finds there to allow the user to do SELECTs, INSERTs, and DELETEs. Categories : Databases, PHP, MySQL, Complete Programs | |
|
|
|