Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 9231

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!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="migration5.changes.html">What has changed in PHP 5.0.x</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="migration5.cli-cgi.html">CLI and CGI</a></div>
 <div class="up"><a href="migration5.html">Migrating from PHP 4 to PHP 5.0.x</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="migration5.incompatible" class="section">
   <h2 class="title">Backward Incompatible Changes</h2>
   <p class="para">
    Although most existing PHP 4 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">
      There are some <a href="reserved.keywords.html" class="link">new reserved
      keywords</a>.
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
       <span class="function"><a href="function.strrpos.html" class="function">strrpos()</a></span> and  <span class="function"><a href="function.strripos.html" class="function">strripos()</a></span> now use
      the entire string as a needle.
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      Illegal use of string offsets causes <strong><code>E_ERROR</code></strong> instead
      of <strong><code>E_WARNING</code></strong>. An example illegal use is: 
      <em>$str = &#039;abc&#039;; unset($str[0]);</em>.
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
       <span class="function"><a href="function.array-merge.html" class="function">array_merge()</a></span> was changed to accept only arrays. If a
      non-array variable is passed, a <strong><code>E_WARNING</code></strong> will be
      thrown for every such parameter. Be careful because your code may start
      emitting <strong><code>E_WARNING</code></strong> out of the blue.
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      <strong><code>PATH_TRANSLATED</code></strong> server variable is no longer set implicitly under
      Apache2 SAPI in contrast to the situation in PHP 4, where it is set to
      the same value as the <strong><code>SCRIPT_FILENAME</code></strong> server variable when it is not
      populated by Apache. This change was made to comply with the <a href="http://www.faqs.org/rfcs/rfc3875" class="link external">&raquo;&nbsp;CGI/1.1 specification</a>. Please refer to <a href="http://bugs.php.net/23610" class="link external">&raquo;&nbsp;bug #23610</a> for further information,
      and see also the <var class="varname"><var class="varname"><a href="reserved.variables.server.html" class="classname">$_SERVER['PATH_TRANSLATED']</a></var></var>
      description in the manual. This issue 
      also affects PHP versions &gt;= 4.3.2.
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      The <strong><code>T_ML_COMMENT</code></strong> constant is no longer defined by
      the <a href="ref.tokenizer.html" class="link">Tokenizer</a> extension. If
      error_reporting is set to <strong><code>E_ALL</code></strong>, PHP will
      generate a notice. Although the <strong><code>T_ML_COMMENT</code></strong> was
      never used at all, it was defined in PHP 4. In both PHP 4 and PHP 5
      // and /* */ are resolved as the <strong><code>T_COMMENT</code></strong>
      constant. However the PHPDoc style comments <em>/** */</em>, which starting PHP
      5 are parsed by PHP, are recognized as <strong><code>T_DOC_COMMENT</code></strong>. 
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      <var class="varname"><var class="varname"><a href="reserved.variables.server.html" class="classname">$_SERVER</a></var></var> should be populated with <var class="varname"><var class="varname">argc</var></var> and
      <var class="varname"><var class="varname">argv</var></var> if
      <a href="ini.core.html#ini.variables-order" class="link">variables_order</a> includes &quot;S&quot;.
      If you have specifically configured your system to not create
      <var class="varname"><var class="varname"><a href="reserved.variables.server.html" class="classname">$_SERVER</a></var></var>, then of course it shouldn&#039;t be there.
      The change was to always make <var class="varname"><var class="varname">argc</var></var>
      and <var class="varname"><var class="varname">argv</var></var> available in the CLI version regardless of the
      <a href="ini.core.html#ini.variables-order" class="link">variables_order</a> setting.
      As in, the CLI version will now always populate the global
      <var class="varname"><var class="varname"><a href="reserved.variables.argc.html" class="classname">$argc</a></var></var> and <var class="varname"><var class="varname"><a href="reserved.variables.argv.html" class="classname">$argv</a></var></var> variables.
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      An object with no properties is no longer considered &quot;empty&quot;.
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      In some cases classes must be declared before use. It only happens if
      some of the new features of PHP 5 (such as <a href="language.oop5.interfaces.html" class="link">interfaces</a>) are used.
      Otherwise the behaviour is the old.
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
       <span class="function"><a href="function.get-class.html" class="function">get_class()</a></span>,  <span class="function"><a href="function.get-parent-class.html" class="function">get_parent_class()</a></span>
      and  <span class="function"><a href="function.get-class-methods.html" class="function">get_class_methods()</a></span> now return the name of the
      classes/methods as they were declared (case-sensitive) which may lead to
      problems in older scripts that rely on the previous behaviour (the
      class/method name was always returned lowercased). A possible solution
      is to search for those functions in all your scripts and use
       <span class="function"><a href="function.strtolower.html" class="function">strtolower()</a></span>.
     </span>
     <span class="simpara">
      This case sensitivity change also applies to the 
      <a href="language.constants.predefined.html" class="link">magical predefined 
      constants</a> <strong><code>__CLASS__</code></strong>, 
      <strong><code>__METHOD__</code></strong>, and <strong><code>__FUNCTION__</code></strong>.
      The values are returned exactly as they&#039;re declared (case-sensitive).
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
       <span class="function"><a href="function.ip2long.html" class="function">ip2long()</a></span> now returns <strong><code>FALSE</code></strong> when an invalid IP
      address is passed as argument to the function, and no longer
      <em>-1</em>.
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      If there are functions defined in the included file, they can be used in the
      main file independent if they are before  <span class="function"><a href="function.return.html" class="function">return</a></span> or after.
      If the file is included twice, PHP 5 issues fatal error because functions
      were already declared, while PHP 4 doesn&#039;t complain about it.
      It is recommended to use  <span class="function"><a href="function.include-once.html" class="function">include_once</a></span> instead of
      checking if the file was already included and conditionally return inside
      the included file.
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
       <span class="function"><a href="function.include-once.html" class="function">include_once</a></span> and  <span class="function"><a href="function.require-once.html" class="function">require_once</a></span>
      first normalize the path of included file on Windows so that including
      A.php and a.php include the file just once.
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      Passing an array to a function by value no longer resets the
      array&#039;s internal pointer for array accesses made within the
      function. In other words, in PHP 4 when you passed an array to a
      function, its internal pointer inside the function would be
      reset, while in PHP 5, when you pass an array to a function, its
      array pointer within the function will be wherever it was when
      the array was passed to the function.
     </span>
    </li>
   </ul>

   <p class="para">
    <div class="example" id="example-5618">
     <p><strong>Example #1  <span class="function"><a href="function.strrpos.html" class="function">strrpos()</a></span> and  <span class="function"><a href="function.strripos.html" class="function">strripos()</a></span> now
      use the entire string as a needle</strong></p>
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">strrpos</span><span style="color: #007700">(</span><span style="color: #DD0000">'ABCDEF'</span><span style="color: #007700">,</span><span style="color: #DD0000">'DEF'</span><span style="color: #007700">));&nbsp;</span><span style="color: #FF8000">//int(3)<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">strrpos</span><span style="color: #007700">(</span><span style="color: #DD0000">'ABCDEF'</span><span style="color: #007700">,</span><span style="color: #DD0000">'DAF'</span><span style="color: #007700">));&nbsp;</span><span style="color: #FF8000">//bool(false)<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
     </div>

    </div>
   </p>
   <p class="para">
    <div class="example" id="example-5619">
     <p><strong>Example #2 An object with no properties is no longer considered &quot;empty&quot;</strong></p>
     <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">test&nbsp;</span><span style="color: #007700">{&nbsp;}<br /></span><span style="color: #0000BB">$t&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">test</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(empty(</span><span style="color: #0000BB">$t</span><span style="color: #007700">));&nbsp;</span><span style="color: #FF8000">//&nbsp;echo&nbsp;bool(false)<br /><br /></span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">$t</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Will&nbsp;be&nbsp;executed<br /></span><span style="color: #007700">}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
     </div>

    </div>
   </p>
   <p class="para">
    <div class="example" id="example-5620">
     <p><strong>Example #3 In some cases classes must be declared before used</strong></p>
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">//works&nbsp;with&nbsp;no&nbsp;errors:<br /></span><span style="color: #0000BB">$a&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">a</span><span style="color: #007700">();<br />class&nbsp;</span><span style="color: #0000BB">a&nbsp;</span><span style="color: #007700">{<br />}<br /><br /><br /></span><span style="color: #FF8000">//throws&nbsp;an&nbsp;error:<br /></span><span style="color: #0000BB">$a&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">b</span><span style="color: #007700">();<br /><br />interface&nbsp;</span><span style="color: #0000BB">c</span><span style="color: #007700">{<br />}<br />class&nbsp;</span><span style="color: #0000BB">b&nbsp;</span><span style="color: #007700">implements&nbsp;</span><span style="color: #0000BB">c&nbsp;</span><span style="color: #007700">{<br />}&nbsp;<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
     </div>

    </div>
   </p>
  </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="migration5.changes.html">What has changed in PHP 5.0.x</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="migration5.cli-cgi.html">CLI and CGI</a></div>
 <div class="up"><a href="migration5.html">Migrating from PHP 4 to PHP 5.0.x</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>