Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > media > main > by-pkgid > 0afeee9cca140e167a996902b9a677c5 > files > 3030

php-manual-en-4.3.0-2mdk.noarch.rpm

<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="Migrating from PHP 3 to PHP 4"
HREF="migration4.html"><LINK
REL="PREVIOUS"
TITLE="Parser behavior"
HREF="migration4.parser.html"><LINK
REL="NEXT"
TITLE="Initializers"
HREF="migration4.initializers.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=ISO-8859-1"></HEAD
><BODY
CLASS="section"
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="migration4.parser.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Appendix B. Migrating from PHP 3 to PHP 4</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="migration4.initializers.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="migration4.error-reporting"
></A
>Error reporting</H1
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="migration4.error-reporting.config"
></A
>Configuration changes</H2
><P
>&#13;     With PHP 3 the error reporting level was set as a simple
     numeric value formed by summing up the numbers related to
     different error levels. Usual values where 15 for reporting all
     errors and warnings or 7 for reporting everything but simple
     notice messages reporting bad style and things like that.
    </P
><P
>&#13;     PHP 4 has a larger set of error and warning levels and comes with a
     configuration parser that now allows for symbolic constants to be used
     for setting the intended behavior.
    </P
><P
>&#13;     Error reporting level should now be configured by explicitly
     taking away the warning levels you do not want to generate error
     messages by x-oring them from the symbolic constant
     <TT
CLASS="literal"
>E_ALL</TT
>. Sounds complicated? Well, lets say you
     want the error reporting system to report all but the simple
     style warnings that are categorized by the symbolic constant
     <TT
CLASS="literal"
>E_NOTICE</TT
>.  Then you'll put the following into
     your <TT
CLASS="filename"
>php.ini</TT
>: <TT
CLASS="literal"
>error_reporting =
     E_ALL &#38; ~ ( E_NOTICE )</TT
>.  If you want to suppress
     warnings too you add up the appropriate constant within the
     braces using the binary or operator '|':
     <TT
CLASS="literal"
>error_reporting= E_ALL &#38; ~ ( E_NOTICE | E_WARNING
     )</TT
>.
    </P
><DIV
CLASS="warning"
><P
></P
><TABLE
CLASS="warning"
BORDER="1"
WIDTH="100%"
><TR
><TD
ALIGN="CENTER"
><B
>Warning</B
></TD
></TR
><TR
><TD
ALIGN="LEFT"
><P
>&#13;      When upgrading code or servers from PHP 3 to PHP 4 you should
      check these settings and calls to
      <A
HREF="function.error-reporting.html"
><B
CLASS="function"
>error_reporting()</B
></A
> or you might disable
      reporting the new error types, especially E_COMPILE_ERROR. This
      may lead to empty documents without any feedback of what happened
      or where to look for the problem.
     </P
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="warning"
><P
></P
><TABLE
CLASS="warning"
BORDER="1"
WIDTH="100%"
><TR
><TD
ALIGN="CENTER"
><B
>Warning</B
></TD
></TR
><TR
><TD
ALIGN="LEFT"
><P
>&#13;      Using the old values 7 and 15 for setting up error reporting is
      a very bad idea as this suppresses some of the newly added error
      classes including parse errors. This may lead to very strange
      behavior as scripts might no longer work without error messages
      showing up anywhere.
     </P
><P
>&#13;      This has lead to a lot of unreproducible bug reports in the
      past where people reported script engine problems they were not
      capable to track down while the <TT
CLASS="constant"
><B
>TRUE</B
></TT
> case was usually some
      missing '}' in a required file that the parser was not able to
      report due to a misconfigured error reporting system.
     </P
><P
>&#13;      So checking your error reporting setup should be the first thing
      to do whenever your scripts silently die. The Zend engine can
      be considered mature enough nowadays to not cause this kind of
      strange behavior.
     </P
></TD
></TR
></TABLE
></DIV
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="migration4.error-reporting.additions"
></A
>Additional warning messages</H2
><P
>&#13;     A lot of existing PHP 3 code uses language constructs that
     should be considered as very bad style as this code, while doing
     the intended thing now, could easily be broken by changes in
     other places. PHP 4 will output a lot of notice messages in
     such situations where PHP 3 didn't.  The easy fix is to just
     turn off E_NOTICE messages, but it is usually a good idea to fix
     the code instead.
    </P
><P
>&#13;     The most common case that will now produce notice messages is the
     use of unquoted string constants as array indices. Both PHP 3
     and 4 will fall back to interpret these as strings if no
     keyword or constant is known by that name, but whenever a
     constant by that name had been defined anywhere else in the code
     it might break your script. This can even become a security risk
     if some intruder manages to redefine string constants in a way
     that makes your script give him access rights he wasn't intended
     to have. So PHP 4 will now warn you whenever you use unquoted
     string constants as for example in
     <TT
CLASS="literal"
>$_SERVER[REQUEST_METHOD]</TT
>. Changing it
     to <TT
CLASS="literal"
>$_SERVER['REQUEST_METHOD']</TT
> will
     make the parser happy and greatly improve the style and security
     of your code.
    </P
><P
>&#13;     Another thing PHP 4 will now tell you about is the use of
     uninitialized variables or array elements.
    </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="migration4.parser.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="migration4.initializers.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Parser behavior</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="migration4.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Initializers</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>