⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 migration52.incompatible.html

📁 php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容
💻 HTML
字号:
<!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 http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="migration52.html">Migrating from PHP 5.1.x to PHP 5.2.x</a></div> <div class="next" style="text-align: right; float: right;"><a href="migration52.error-messages.html">New Error Messages</a></div> <div class="up"><a href="migration52.html">Migrating from PHP 5.1.x to PHP 5.2.x</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="migration52.incompatible" class="section">  <h2 class="title">Backward Incompatible Changes</h2>  <p class="para">   Although most existing PHP 5 code should work without changes, you should   pay attention to the following backward incompatible changes:  </p>  <ul class="itemizedlist">   <li class="listitem">    <span class="simpara">     <a href="function.getrusage.html" class="function">getrusage()</a> returns <b><tt>NULL</tt></b> when passed     incompatible arguments as of PHP 5.2.1.    </span>   </li>   <li class="listitem">    <span class="simpara">     <a href="function.ziparchive-setCommentName.html" class="link"><a href="function.ziparchive-setCommentName.html" class="function">ZipArchive::setCommentName()</a></a>     returns <b><tt>TRUE</tt></b> on success as of PHP 5.2.1.    </span>   </li>   <li class="listitem">    <span class="simpara">     <a href="function.ziparchive-setcommentindex.html" class="link"><a href="function.ziparchive-setcommentindex.html" class="function">ZipArchive::setCommentIndex()</a></a>     returns <b><tt>TRUE</tt></b> on success as of PHP 5.2.1.    </span>   </li>   <li class="listitem">    <span class="simpara">     <b>SplFileObject::getFilename()</b> returns     the filename, not relative/path/to/file, as of PHP 5.2.1.    </span>   </li>   <li class="listitem">    <span class="simpara">     Changed priority of <var class="varname">PHPRC</var> environment variable on Win32    </span>    <span class="simpara">     The <var class="varname">PHPRC</var> environment variable now takes priority over the path stored     in the Windows registry.    </span>   </li>   <li class="listitem">    <span class="simpara">     CLI SAPI no longer checks cwd for <var class="filename">php.ini</var> or the <var class="filename">php-cli.ini</var> file    </span>    <span class="simpara">     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 <var class="filename">php.ini</var> or <var class="filename">php-cli.ini</var> files.     See also the <a href="features.commandline.html" class="link">command line</a> section     of the manual.    </span>   </li>   <li class="listitem">    <span class="simpara">     Added a warning when performing modulus 0 operations    </span>    <span class="simpara">     In earlier versions of PHP, performing integer % 0 did not emit any     warning messages, instead returning an unexpected return value of <b><tt>FALSE</tt></b>.     As of PHP 5.2.0, this operation will emit an <b><tt>E_WARNING</tt></b>,      as is the case in all other instances where division by zero is performed.    </span>    <div class="informalexample">     <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">print&nbsp;</span><span style="color: #0000BB">10&nbsp;</span><span style="color: #007700">%&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">;<br /></span><span style="color: #FF8000">/*&nbsp;Warning:&nbsp;&nbsp;Division&nbsp;by&nbsp;zero&nbsp;in&nbsp;filename&nbsp;on&nbsp;line&nbsp;n&nbsp;*/<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>     </div>    </div>   </li>   <li class="listitem">    <span class="simpara">     Changed <b>__toString()</b> to be called wherever     applicable.    </span>    <span class="simpara">     The magic method <b>__toString()</b> will now be called     in a string context, that is, anywhere an object is used as a     string.    </span>    <span class="simpara">     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.    </span>    <div class="informalexample">     <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">foo&nbsp;</span><span style="color: #007700">{}<br /></span><span style="color: #0000BB">$foo&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">foo</span><span style="color: #007700">;<br />print&nbsp;</span><span style="color: #0000BB">$foo</span><span style="color: #007700">;<br /></span><span style="color: #FF8000">/*&nbsp;Catchable&nbsp;fatal&nbsp;error:&nbsp;&nbsp;Object&nbsp;of&nbsp;class&nbsp;foo&nbsp;could<br />&nbsp;&nbsp;&nbsp;not&nbsp;be&nbsp;converted&nbsp;to&nbsp;string&nbsp;in&nbsp;filename&nbsp;on&nbsp;line&nbsp;n&nbsp;*/<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>     </div>    </div>    <span class="simpara">     Even with <b>__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" class="function">spl_object_hash()</a>.    </span>    <span class="simpara">     Exceptions can not be thrown from     <b>__toString()</b> methods.    </span>    <div class="informalexample">     <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">foo&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #0000BB">__toString</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw&nbsp;new&nbsp;</span><span style="color: #0000BB">Exception</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br />try&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;new&nbsp;</span><span style="color: #0000BB">foo</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">/*&nbsp;Fatal&nbsp;error:&nbsp;&nbsp;Method&nbsp;foo::__toString()&nbsp;must<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;not&nbsp;throw&nbsp;an&nbsp;exception&nbsp;in&nbsp;filename&nbsp;on&nbsp;line&nbsp;n&nbsp;*/<br /></span><span style="color: #007700">}&nbsp;catch(</span><span style="color: #0000BB">Exception&nbsp;$e</span><span style="color: #007700">)&nbsp;{}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>     </div>    </div>   </li>   <li class="listitem">    <span class="simpara">     Dropped abstract static class functions.    </span>    <span class="simpara">     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.    </span>    <div class="informalexample">     <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">abstract&nbsp;class&nbsp;</span><span style="color: #0000BB">foo&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;abstract&nbsp;static&nbsp;function&nbsp;</span><span style="color: #0000BB">bar</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">/*&nbsp;Strict&nbsp;Standards:&nbsp;&nbsp;Static&nbsp;function&nbsp;foo::bar()<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;should&nbsp;not&nbsp;be&nbsp;abstract&nbsp;in&nbsp;filename&nbsp;on&nbsp;line&nbsp;n&nbsp;*/<br /></span><span style="color: #007700">}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>     </div>    </div>   </li>   <li class="listitem">    <span class="simpara">     <a href="ref.oci8.html" class="link">Oracle extension</a> requires at least Oracle     10 on Windows.    </span>   </li>   <li class="listitem">    <span class="simpara">     Added RFC2397 (<i>data:</i> stream) support.    </span>    <span class="simpara">     The introduction of the &#039;data&#039; URL scheme has the potential to lead to a     change of behavior under Windows. If you are working with a <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 &#039;data:&#039; that is accessed without     any path information - it won&#039;t work any more. The fix is to use the &#039;file:&#039;     protocol when accessing it.    </span>    <span class="simpara">     See also <a href="http://www.faqs.org/rfcs/rfc2397" class="link external">&raquo; RFC 2397</a>     </span>    <div class="informalexample">     <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/*&nbsp;when&nbsp;allow_url_include&nbsp;is&nbsp;OFF&nbsp;(default)&nbsp;*/<br /></span><span style="color: #007700">include&nbsp;</span><span style="color: #DD0000">"data:;base64,PD9waHAgcGhwaW5mbygpOz8+"</span><span style="color: #007700">;<br /></span><span style="color: #FF8000">/*&nbsp;Warning:&nbsp;&nbsp;include():&nbsp;URL&nbsp;file-access&nbsp;is&nbsp;disabled<br />&nbsp;&nbsp;&nbsp;in&nbsp;the&nbsp;server&nbsp;configuration&nbsp;in&nbsp;filename&nbsp;on&nbsp;line&nbsp;n&nbsp;*/<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>     </div>    </div>   </li>   <li class="listitem">    <span class="simpara">     Regression in <i>glob()</i> patterns    </span>    <span class="simpara">     In version 5.2.4 a security fix caused a regression for patterns of     the form &quot;/foo/*/bar/*&quot;. Since version 5.2.5 instead of raising a warning the     <i>glob()</i> function will return <b><tt>FALSE</tt></b> when     <i>openbase_dir</i> restrictions are violated.    </span>   </li>  </ul> </div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="migration52.html">Migrating from PHP 5.1.x to PHP 5.2.x</a></div> <div class="next" style="text-align: right; float: right;"><a href="migration52.error-messages.html">New Error Messages</a></div> <div class="up"><a href="migration52.html">Migrating from PHP 5.1.x to PHP 5.2.x</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -