Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 05cd670d8a02b2b4a0ffb1756f2e8308 > files > 898

php-manual-zh-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
>error_reporting</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="PHP 手册"
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=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"
>PHP 手册</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.error-log.html"
ACCESSKEY="P"
>上一页</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"
>下一页</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="AEN47567"
></A
><P
>    (PHP 3, PHP 4, PHP 5)</P
>error_reporting&nbsp;--&nbsp;Sets which PHP errors are reported</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN47570"
></A
><H2
>说明</H2
>int <B
CLASS="methodname"
>error_reporting</B
> ( [int level] )<BR
></BR
><P
>&#13;   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
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN47581"
></A
><H2
>参数</H2
><P
>&#13;   <P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><CODE
CLASS="parameter"
>level</CODE
></DT
><DD
><P
>&#13;       The new <A
HREF="ref.errorfunc.html#ini.error-reporting"
>error_reporting</A
>
       level. It 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
>&#13;       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="AEN47593"
></A
><P
><B
>表 1. <B
CLASS="function"
>error_reporting()</B
> level constants and bit values</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><THEAD
><TR
><TH
>value</TH
><TH
>constant</TH
></TR
></THEAD
><TBODY
><TR
><TD
>1</TD
><TD
>&#13;            <A
HREF="ref.errorfunc.html#e-error"
>E_ERROR</A
>
           </TD
></TR
><TR
><TD
>2</TD
><TD
>&#13;            <A
HREF="ref.errorfunc.html#e-warning"
>E_WARNING</A
>
           </TD
></TR
><TR
><TD
>4</TD
><TD
>&#13;            <A
HREF="ref.errorfunc.html#e-parse"
>E_PARSE</A
>
           </TD
></TR
><TR
><TD
>8</TD
><TD
>&#13;            <A
HREF="ref.errorfunc.html#e-notice"
>E_NOTICE</A
>
           </TD
></TR
><TR
><TD
>16</TD
><TD
>&#13;            <A
HREF="ref.errorfunc.html#e-core-error"
>E_CORE_ERROR</A
>
           </TD
></TR
><TR
><TD
>32</TD
><TD
>&#13;            <A
HREF="ref.errorfunc.html#e-core-warning"
>E_CORE_WARNING</A
>
           </TD
></TR
><TR
><TD
>64</TD
><TD
>&#13;            <A
HREF="ref.errorfunc.html#e-compile-error"
>E_COMPILE_ERROR</A
>
           </TD
></TR
><TR
><TD
>128</TD
><TD
>&#13;            <A
HREF="ref.errorfunc.html#e-compile-warning"
>E_COMPILE_WARNING</A
>
           </TD
></TR
><TR
><TD
>256</TD
><TD
>&#13;            <A
HREF="ref.errorfunc.html#e-user-error"
>E_USER_ERROR</A
>
           </TD
></TR
><TR
><TD
>512</TD
><TD
>&#13;            <A
HREF="ref.errorfunc.html#e-user-warning"
>E_USER_WARNING</A
>
           </TD
></TR
><TR
><TD
>1024</TD
><TD
>&#13;            <A
HREF="ref.errorfunc.html#e-user-error"
>E_USER_NOTICE</A
>
           </TD
></TR
><TR
><TD
>6143</TD
><TD
>&#13;           <A
HREF="ref.errorfunc.html#e-all"
>E_ALL</A
>
           </TD
></TR
><TR
><TD
>2048</TD
><TD
>&#13;            <A
HREF="ref.errorfunc.html#e-strict"
>E_STRICT</A
>
           </TD
></TR
><TR
><TD
>4096</TD
><TD
>&#13;            <A
HREF="ref.errorfunc.html#e-recoverable-error"
>E_RECOVERABLE_ERROR</A
>
           </TD
></TR
></TBODY
></TABLE
></DIV
>
      </P
></DD
></DL
></DIV
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN47658"
></A
><H2
>返回值</H2
><P
>&#13;   Returns the old <A
HREF="ref.errorfunc.html#ini.error-reporting"
>error_reporting</A
>
   level.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN47662"
></A
><H2
>更新日志</H2
><P
>&#13;   <DIV
CLASS="informaltable"
><P
></P
><A
NAME="AEN47665"
></A
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><THEAD
><TR
><TH
>版本</TH
><TH
>说明</TH
></TR
></THEAD
><TBODY
><TR
><TD
>5.0.0</TD
><TD
><TT
CLASS="constant"
><B
>E_STRICT</B
></TT
> introduced (not part of <TT
CLASS="constant"
><B
>E_ALL</B
></TT
>).</TD
></TR
><TR
><TD
>5.2.0</TD
><TD
><TT
CLASS="constant"
><B
>E_RECOVERABLE_ERROR</B
></TT
> introduced.</TD
></TR
><TR
><TD
>6</TD
><TD
><TT
CLASS="constant"
><B
>E_STRICT</B
></TT
> became part of <TT
CLASS="constant"
><B
>E_ALL</B
></TT
>.</TD
></TR
></TBODY
></TABLE
><P
></P
></DIV
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN47686"
></A
><H2
>范例</H2
><P
>&#13;   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN47689"
></A
><P
><B
>例 1. <B
CLASS="function"
>error_reporting()</B
> examples</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /><br /></font><font color="#FF8000">// Turn off all error reporting<br /></font><font color="#0000BB">error_reporting</font><font color="#007700">(</font><font color="#0000BB">0</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// Report simple running errors<br /></font><font color="#0000BB">error_reporting</font><font color="#007700">(</font><font color="#0000BB">E_ERROR </font><font color="#007700">| </font><font color="#0000BB">E_WARNING </font><font color="#007700">| </font><font color="#0000BB">E_PARSE</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// Reporting E_NOTICE can be good too (to report uninitialized<br />// variables or catch variable name misspellings ...)<br /></font><font color="#0000BB">error_reporting</font><font color="#007700">(</font><font color="#0000BB">E_ERROR </font><font color="#007700">| </font><font color="#0000BB">E_WARNING </font><font color="#007700">| </font><font color="#0000BB">E_PARSE </font><font color="#007700">| </font><font color="#0000BB">E_NOTICE</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// Report all errors except E_NOTICE<br />// This is the default value set in php.ini<br /></font><font color="#0000BB">error_reporting</font><font color="#007700">(</font><font color="#0000BB">E_ALL </font><font color="#007700">^ </font><font color="#0000BB">E_NOTICE</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// Report all PHP errors (bitwise 63 may be used in PHP 3)<br /></font><font color="#0000BB">error_reporting</font><font color="#007700">(</font><font color="#0000BB">E_ALL</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// Same as error_reporting(E_ALL);<br /></font><font color="#0000BB">ini_set</font><font color="#007700">(</font><font color="#DD0000">'error_reporting'</font><font color="#007700">, </font><font color="#0000BB">E_ALL</font><font color="#007700">);<br /><br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN47693"
></A
><H2
>注释</H2
><DIV
CLASS="warning"
><P
></P
><TABLE
CLASS="warning"
BORDER="1"
WIDTH="100%"
><TR
><TD
ALIGN="CENTER"
><B
>警告</B
></TD
></TR
><TR
><TD
ALIGN="LEFT"
><P
>&#13;    Most of <TT
CLASS="constant"
><B
>E_STRICT</B
></TT
> errors are evaluated at the
    compile time thus such errors are not reported in the file where
    <A
HREF="ref.errorfunc.html#ini.error-reporting"
>error_reporting</A
> is enhanced
    to include <TT
CLASS="constant"
><B
>E_STRICT</B
></TT
> errors (and vice versa).
   </P
></TD
></TR
></TABLE
></DIV
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN47700"
></A
><H2
>参见</H2
><P
>&#13;   <P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
>The <A
HREF="ref.errorfunc.html#ini.display-errors"
>display_errors</A
> directive</TD
></TR
><TR
><TD
><A
HREF="function.ini-set.html"
><B
CLASS="function"
>ini_set()</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.error-log.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>起始页</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.restore-error-handler.html"
ACCESSKEY="N"
>下一页</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"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>restore_error_handler</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>