Source of: /manual/en/migration52.incompatible.php
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/migration52.inc";
$setup = array (
'home' =>
array (
0 => 'index.php',
1 => 'PHP Manual',
),
'head' =>
array (
0 => 'UTF-8',
1 => 'en',
),
'this' =>
array (
0 => 'migration52.incompatible.php',
1 => 'Backward Incompatible Changes',
),
'up' =>
array (
0 => 'migration52.php',
1 => 'Migrating from PHP 5.1.x to PHP 5.2.x',
),
'prev' =>
array (
0 => 'migration52.changes.php',
1 => 'What has changed in PHP 5.2.x',
),
'next' =>
array (
0 => 'migration52.error-messages.php',
1 => 'New Error Messages',
),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);
manual_header();
?>
<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.php" class="function">getrusage()</a> returns <b><tt class="constant">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.php" class="function">ZipArchive::setCommentName()</a>
returns <b><tt class="constant">TRUE</tt></b> on success as of PHP 5.2.1.
</span>
</li>
<li class="listitem">
<span class="simpara">
<a href="function.ziparchive-setcommentindex.php" class="function">ZipArchive::setCommentIndex()</a>
returns <b><tt class="constant">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.php" 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 class="constant">FALSE</tt></b>.
As of PHP 5.2.0, this operation will emit an <b><tt class="constant">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 programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB"><?php<br /></span><span style="color: #007700">print </span><span style="color: #0000BB">10 </span><span style="color: #007700">% </span><span style="color: #0000BB">0</span><span style="color: #007700">;<br /></span><span style="color: #FF8000">/* Warning: Division by zero in filename on line n */<br /></span><span style="color: #0000BB">?></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 programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB"><?php<br /></span><span style="color: #007700">class </span><span style="color: #0000BB">foo </span><span style="color: #007700">{}<br /></span><span style="color: #0000BB">$foo </span><span style="color: #007700">= new </span><span style="color: #0000BB">foo</span><span style="color: #007700">;<br />print </span><span style="color: #0000BB">$foo</span><span style="color: #007700">;<br /></span><span style="color: #FF8000">/* Catchable fatal error: Object of class foo could<br /> not be converted to string in filename on line n */<br /></span><span style="color: #0000BB">?></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.php" 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 programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB"><?php<br /></span><span style="color: #007700">class </span><span style="color: #0000BB">foo </span><span style="color: #007700">{<br /> public function </span><span style="color: #0000BB">__toString</span><span style="color: #007700">() {<br /> throw new </span><span style="color: #0000BB">Exception</span><span style="color: #007700">;<br /> }<br />}<br /><br />try {<br /> print new </span><span style="color: #0000BB">foo</span><span style="color: #007700">;<br /> </span><span style="color: #FF8000">/* Fatal error: Method foo::__toString() must<br /> not throw an exception in filename on line n */<br /></span><span style="color: #007700">} catch(</span><span style="color: #0000BB">Exception $e</span><span style="color: #007700">) {}<br /></span><span style="color: #0000BB">?></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 programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB"><?php<br /></span><span style="color: #007700">abstract class </span><span style="color: #0000BB">foo </span><span style="color: #007700">{<br /> abstract static function </span><span style="color: #0000BB">bar</span><span style="color: #007700">();<br /> </span><span style="color: #FF8000">/* Strict Standards: Static function foo::bar()<br /> should not be abstract in filename on line n */<br /></span><span style="color: #007700">}<br /></span><span style="color: #0000BB">?></span>
</span>
</code></div>
</div>
</div>
</li>
<li class="listitem">
<span class="simpara">
<a href="ref.oci8.php" 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 'data' 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 '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.
</span>
<span class="simpara">
See also <a href="http://www.faqs.org/rfcs/rfc2397" class="link external">» RFC 2397</a>
</span>
<div class="informalexample">
<div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">/* when allow_url_include is OFF (default) */<br /></span><span style="color: #007700">include </span><span style="color: #DD0000">"data:;base64,PD9waHAgcGhwaW5mbygpOz8+"</span><span style="color: #007700">;<br /></span><span style="color: #FF8000">/* Warning: include(): URL file-access is disabled<br /> in the server configuration in filename on line n */<br /></span><span style="color: #0000BB">?></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 "/foo/*/bar/*". Since version 5.2.5 instead of raising a warning the
<i>glob()</i> function will return <b><tt class="constant">FALSE</tt></b> when
<i>openbase_dir</i> restrictions are violated.
</span>
</li>
</ul>
</div><?php manual_footer(); ?>