Sophie

Sophie

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

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
>Backward Incompatible Changes</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="PHP 手册"
HREF="index.html"><LINK
REL="UP"
TITLE="Migrating from PHP 5.1.x to PHP 5.2.x"
HREF="migration52.html"><LINK
REL="PREVIOUS"
TITLE="Migrating from PHP 5.1.x to PHP 5.2.x"
HREF="migration52.html"><LINK
REL="NEXT"
TITLE="New Error Messages"
HREF="migration52.error-messages.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=UTF-8"></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 手册</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="migration52.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>附录 B. Migrating from PHP 5.1.x to PHP 5.2.x</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="migration52.error-messages.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="migration52.incompatible"
>Backward Incompatible Changes</A
></H1
><P
>&#13;   Although most existing PHP 5 code should work without changes, you should
   pay attention to the following backward incompatible changes:
  </P
><P
></P
><UL
><LI
><P
>&#13;     <A
HREF="function.getrusage.html"
><B
CLASS="function"
>getrusage()</B
></A
> returns <TT
CLASS="constant"
><B
>NULL</B
></TT
> when passed
     incompatible arguments as of PHP 5.2.1.
    </P
></LI
><LI
><P
>&#13;     <A
HREF="function.ziparchive-setcommentname.html"
><B
CLASS="function"
>ZipArchive::setCommentName()</B
></A
>
     returns <TT
CLASS="constant"
><B
>TRUE</B
></TT
> on success as of PHP 5.2.1.
    </P
></LI
><LI
><P
>&#13;     <A
HREF="function.ziparchive-setcommentindex.html"
><B
CLASS="function"
>ZipArchive::setCommentIndex()</B
></A
>
     returns <TT
CLASS="constant"
><B
>TRUE</B
></TT
> on success as of PHP 5.2.1.
    </P
></LI
><LI
><P
>&#13;     <B
CLASS="function"
>SplFileObject::getFilename()</B
> returns
     the filename, not relative/path/to/file, as of PHP 5.2.1.
    </P
></LI
><LI
><P
>&#13;     Changed priority of <TT
CLASS="constant"
><B
>PHPRC</B
></TT
> environment variable on Win32
    </P
><P
>&#13;     The PHPRC environment variable now takes priority over the path stored
     in the Windows registry.
    </P
></LI
><LI
><P
>&#13;     CLI SAPI no longer checks cwd for <TT
CLASS="filename"
>php.ini</TT
> or the <TT
CLASS="filename"
>php-cli.ini</TT
> file
    </P
><P
>&#13;     In PHP 5.1.x an undocumented feature was added that made the CLI binary check
     the current working directory for a PHP configuration file, potentially
     leading to unpredictable behavior if an unexpected configuration file were
     read. This functionality was removed in 5.2.0, and PHP will no longer search
     CWD for the presence of <TT
CLASS="filename"
>php.ini</TT
> or <TT
CLASS="filename"
>php-cli.ini</TT
> files.
     See also the <A
HREF="features.commandline.html"
>command line</A
> section
     of the manual.
    </P
></LI
><LI
><P
>&#13;     Added a warning when performing modulus 0 operations
    </P
><P
>&#13;     In earlier versions of PHP, performing integer % 0 did not emit any
     warning messages, instead returning an unexpected return value of <TT
CLASS="constant"
><B
>FALSE</B
></TT
>.
     As of PHP 5.2.0, this operation will emit an <TT
CLASS="constant"
><B
>E_WARNING</B
></TT
>, 
     as is the case in all other instances where division by zero is performed.
    </P
><DIV
CLASS="informalexample"
><P
></P
><A
NAME="AEN289342"
></A
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#007700">print </font><font color="#0000BB">10 </font><font color="#007700">% </font><font color="#0000BB">0</font><font color="#007700">;<br /></font><font color="#FF8000">/* Warning:&nbsp;&nbsp;Division by zero in filename on line n */<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
></P
></DIV
></LI
><LI
><P
>&#13;     Changed <B
CLASS="function"
>__toString()</B
> to be called wherever
     applicable.
    </P
><P
>&#13;     The magic method <B
CLASS="function"
>__toString()</B
> will now be called
     in a string context, that is, anywhere an object is used as a
     string.
    </P
><P
>&#13;     The fallback of returning a string that contains the
     object identifier was dropped in PHP 5.2.0.  It became
     problematic because an object identifier cannot be considered
     unique. This change will mean that your application is flawed if you
     have relied on the object identifier as a return value.  An attempt
     to use that value as a string will now result in a catchable fatal
     error.
    </P
><DIV
CLASS="informalexample"
><P
></P
><A
NAME="AEN289350"
></A
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#007700">class </font><font color="#0000BB">foo </font><font color="#007700">{}<br /></font><font color="#0000BB">$foo </font><font color="#007700">= new </font><font color="#0000BB">foo</font><font color="#007700">;<br />print </font><font color="#0000BB">$foo</font><font color="#007700">;<br /></font><font color="#FF8000">/* Catchable fatal error:&nbsp;&nbsp;Object of class foo could<br />&nbsp;&nbsp;&nbsp;not be converted to string in filename on line n */<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
></P
></DIV
><P
>&#13;     Even with <B
CLASS="function"
>__toString()</B
>, objects cannot be used as
     array indices or keys. We may add built-in hash support for this at
     a later date, but as of PHP 5.2.x you will need to either provide your
     own hashing or use the new SPL function
     <A
HREF="function.spl-object-hash.html"
><B
CLASS="function"
>spl_object_hash()</B
></A
>.
    </P
><P
>&#13;     Exceptions can not be thrown from
     <B
CLASS="function"
>__toString()</B
> methods.
    </P
><DIV
CLASS="informalexample"
><P
></P
><A
NAME="AEN289357"
></A
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#007700">class </font><font color="#0000BB">foo </font><font color="#007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">public </font><font color="#007700">function </font><font color="#0000BB">__toString</font><font color="#007700">() {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">throw </font><font color="#007700">new </font><font color="#0000BB">Exception</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br /></font><font color="#0000BB">try </font><font color="#007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;print new </font><font color="#0000BB">foo</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">/* Fatal error:&nbsp;&nbsp;Method foo::__toString() must<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;not throw an exception in filename on line n */<br /></font><font color="#007700">} </font><font color="#0000BB">catch</font><font color="#007700">(</font><font color="#0000BB">Exception $e</font><font color="#007700">) {}<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
></P
></DIV
></LI
><LI
><P
>&#13;     Dropped abstract static class functions.
    </P
><P
>&#13;     Due to an oversight, PHP 5.0.x and 5.1.x allowed abstract static 
     functions in classes. As of PHP 5.2.x, only interfaces can have them.
    </P
><DIV
CLASS="informalexample"
><P
></P
><A
NAME="AEN289362"
></A
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />abstract </font><font color="#007700">class </font><font color="#0000BB">foo </font><font color="#007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">abstract </font><font color="#007700">static function </font><font color="#0000BB">bar</font><font color="#007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">/* Strict Standards:&nbsp;&nbsp;Static function foo::bar()<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;should not be abstract in filename on line n */<br /></font><font color="#007700">}<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
></P
></DIV
></LI
><LI
><P
>&#13;     Added RFC2397 (<TT
CLASS="literal"
>data:</TT
> stream) support.
    </P
><P
>&#13;     The introduction of the 'data' URL scheme has the potential to lead to a
     change of behavior under Windows. If you are working with a <ACRONYM
CLASS="acronym"
>NTFS</ACRONYM
>
     file system and making use of meta streams in your application, and if you
     just happen to be using a file with the name 'data:' that is accessed without
     any path information - it won't work any more. The fix is to use the 'file:'
     protocol when accessing it.
    </P
><P
>&#13;     See also <A
HREF="http://www.faqs.org/rfcs/rfc2397"
TARGET="_top"
>RFC 2397</A
> 
    </P
><DIV
CLASS="informalexample"
><P
></P
><A
NAME="AEN289371"
></A
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#FF8000">/* when allow_url_include is OFF (default) */<br /></font><font color="#007700">include </font><font color="#DD0000">"data:;base64,PD9waHAgcGhwaW5mbygpOz8+"</font><font color="#007700">;<br /></font><font color="#FF8000">/* Warning:&nbsp;&nbsp;include(): URL file-access is disabled<br />&nbsp;&nbsp;&nbsp;in the server configuration in filename on line n */<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
></P
></DIV
></LI
></UL
></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="migration52.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="migration52.error-messages.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Migrating from PHP 5.1.x to PHP 5.2.x</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="migration52.html"
ACCESSKEY="U"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>New Error Messages</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>