<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Backward Incompatible Changes</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="migration54.changes.html">What has changed in PHP 5.4.x</a></div> <div class="next" style="text-align: right; float: right;"><a href="migration54.new-features.html">New features</a></div> <div class="up"><a href="migration54.html">Migrating from PHP 5.3.x to PHP 5.4.x</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="migration54.incompatible" class="section"> <h2 class="title">Backward Incompatible Changes</h2> <p class="simpara"> Although most existing PHP 5 code should work without changes, please take note of some backward incompatible changes: </p> <ul class="itemizedlist"> <li class="listitem"> <span class="simpara"> <a href="features.safe-mode.html" class="link">Safe mode</a> is no longer supported. Any applications that rely on safe mode may need adjustment, in terms of security. </span> </li> <li class="listitem"> <span class="simpara"> <a href="security.magicquotes.html" class="link">Magic quotes</a> has been removed. Applications relying on this feature may need to be updated, to avoid security issues. </span> <span class="simpara"> <span class="function"><a href="function.get-magic-quotes-gpc.html" class="function">get_magic_quotes_gpc()</a></span> and <span class="function"><a href="function.get-magic-quotes-runtime.html" class="function">get_magic_quotes_runtime()</a></span> now always return <strong><code>FALSE</code></strong>. <span class="function"><a href="function.set-magic-quotes-runtime.html" class="function">set_magic_quotes_runtime()</a></span> raises an <strong><code>E_CORE_ERROR</code></strong> level error on trying to enable <a href="security.magicquotes.html" class="link">Magic quotes</a>. </span> </li> <li class="listitem"> <span class="simpara"> The <a href="ini.core.html#ini.register-globals" class="link">register_globals</a> and <a href="ini.core.html#ini.register-long-arrays" class="link">register_long_arrays</a> <var class="filename">php.ini</var> directives have been removed. </span> </li> <li class="listitem"> <span class="simpara"> The mbstring.script_encoding directive has been removed. Use <a href="ini.core.html#ini.zend.script-encoding" class="link">zend.script_encoding</a> instead. </span> </li> <li class="listitem"> <span class="simpara"> <a href="language.references.pass.html" class="link">Call-time pass by reference</a> has been removed. </span> </li> <li class="listitem"> <span class="simpara"> The <a href="control-structures.break.html" class="link">break</a> and <a href="control-structures.continue.html" class="link">continue</a> statements no longer accept variable arguments (e.g., <em>break 1 + foo() * $bar;</em>). Static arguments still work, such as <em>break 2;</em>. As a side effect of this change <em>break 0;</em> and <em>continue 0;</em> are no longer allowed. </span> </li> <li class="listitem"> <span class="simpara"> In the <a href="book.datetime.html" class="link">date and time extension</a>, the timezone can no longer be set using the TZ environment variable. Instead you have to specify a timezone using the <a href="datetime.configuration.html#ini.date.timezone" class="link">date.timezone</a> <var class="filename">php.ini</var> option or <span class="function"><a href="function.date-default-timezone-set.html" class="function">date_default_timezone_set()</a></span> function. PHP will no longer attempt to guess the timezone, and will instead fall back to "UTC" and issue a <strong><code>E_WARNING</code></strong>. </span> </li> <li class="listitem"> <span class="simpara"> Non-numeric string offsets - e.g. <em>$a['foo']</em> where $a is a string - now return false on <span class="function"><a href="function.isset.html" class="function">isset()</a></span> and true on <span class="function"><a href="function.empty.html" class="function">empty()</a></span>, and produce a <strong><code>E_WARNING</code></strong> if you try to use them. Offsets of types double, bool and null produce a <strong><code>E_NOTICE</code></strong>. Numeric strings (e.g. <em>$a['2']</em>) still work as before. Note that offsets like <em>'12.3'</em> and <em>'5 foobar'</em> are considered non-numeric and produce a <strong><code>E_WARNING</code></strong>, but are converted to 12 and 5 respectively, for backward compatibility reasons. </span> <span class="simpara"> Note: Following code returns different result. </span> <span class="simpara"> $str='abc';var_dump(isset($str['x'])); // false for PHP 5.4 or later, but true for 5.3 or less </span> </li> <li class="listitem"> <span class="simpara"> Converting an array to a string will now generate an <strong><code>E_NOTICE</code></strong> level error, but the result of the cast will still be the string <em>"Array"</em>. </span> </li> <li class="listitem"> <span class="simpara"> Turning <strong><code>NULL</code></strong>, <strong><code>FALSE</code></strong>, or an empty string into an object by adding a property will now emit an <strong><code>E_WARNING</code></strong> level error, instead of <strong><code>E_STRICT</code></strong>. </span> </li> <li class="listitem"> <span class="simpara"> Parameter names that shadow super globals now cause a fatal error. This prohibits code like <em>function foo($_GET, $_POST) {}</em>. </span> </li> <li class="listitem"> <span class="simpara"> The Salsa10 and Salsa20 <a href="book.hash.html" class="link">hash algorithms</a> have been removed. </span> </li> <li class="listitem"> <span class="simpara"> The Tiger <a href="book.hash.html" class="link">hash algorithm</a> now uses big-endian byte ordering. Please follow <a href="function.hash.html#function.hash.tiger-bc" class="link">this example</a> to write code that is compatible with both PHP 5.3 and 5.4. </span> </li> <li class="listitem"> <span class="simpara"> <span class="function"><a href="function.array-combine.html" class="function">array_combine()</a></span> now returns <em>array()</em> instead of <strong><code>FALSE</code></strong> when two empty arrays are provided as parameters. </span> </li> <li class="listitem"> <span class="simpara"> If you use <span class="function"><a href="function.htmlentities.html" class="function">htmlentities()</a></span> with asian character sets, it works like <span class="function"><a href="function.htmlspecialchars.html" class="function">htmlspecialchars()</a></span> - this has always been the case in previous versions of PHP, but now an <strong><code>E_STRICT</code></strong> level error is emitted. </span> </li> <li class="listitem"> <span class="simpara"> The third parameter of <span class="function"><a href="function.ob-start.html" class="function">ob_start()</a></span> has changed from <span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span> <code class="parameter">erase</code> to <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span> <code class="parameter">flags</code>. Note that code that explicitly set <code class="parameter">erase</code> to <strong><code>FALSE</code></strong> will no longer behave as expected in PHP 5.4: please follow <a href="function.ob-start.html#function.ob-start.flags-bc" class="link">this example</a> to write code that is compatible with PHP 5.3 and 5.4. </span> </li> </ul> <p class="simpara"> The following keywords are now <a href="reserved.html" class="link">reserved</a>, and may not be used as names by functions, classes, etc. </p> <ul class="itemizedlist"> <li class="listitem"> <span class="simpara"> <a href="language.oop5.traits.html" class="link">trait</a> </span> </li> <li class="listitem"> <span class="simpara"> <a href="language.types.callable.html" class="link">callable</a> </span> </li> <li class="listitem"> <span class="simpara"> <a href="language.oop5.traits.html" class="link">insteadof</a> </span> </li> </ul> <p class="simpara"> The following functions have been removed from PHP: </p> <ul class="itemizedlist"> <li class="listitem"> <span class="simpara"> <span class="function"><a href="function.define-syslog-variables.html" class="function">define_syslog_variables()</a></span> </span> </li> <li class="listitem"> <span class="simpara"> <span class="function"><a href="function.import-request-variables.html" class="function">import_request_variables()</a></span> </span> </li> <li class="listitem"> <span class="simpara"> <span class="function"><a href="function.session-is-registered.html" class="function">session_is_registered()</a></span>, <span class="function"><a href="function.session-register.html" class="function">session_register()</a></span> and <span class="function"><a href="function.session-unregister.html" class="function">session_unregister()</a></span>. </span> </li> <li class="listitem"> <span class="simpara"> The aliases <span class="function"><a href="function.mysqli-bind-param.html" class="function">mysqli_bind_param()</a></span>, <span class="function"><a href="function.mysqli-bind-result.html" class="function">mysqli_bind_result()</a></span>, <span class="function"><a href="function.mysqli-client-encoding.html" class="function">mysqli_client_encoding()</a></span>, <span class="function"><a href="function.mysqli-fetch.html" class="function">mysqli_fetch()</a></span>, <span class="function"><a href="function.mysqli-param-count.html" class="function">mysqli_param_count()</a></span>, <span class="function"><a href="function.mysqli-get-metadata.html" class="function">mysqli_get_metadata()</a></span>, <span class="function"><a href="function.mysqli-send-long-data.html" class="function">mysqli_send_long_data()</a></span>, mysqli::client_encoding() and mysqli_stmt::stmt(). </span> </li> </ul> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="migration54.changes.html">What has changed in PHP 5.4.x</a></div> <div class="next" style="text-align: right; float: right;"><a href="migration54.new-features.html">New features</a></div> <div class="up"><a href="migration54.html">Migrating from PHP 5.3.x to PHP 5.4.x</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>