Sophie

Sophie

distrib > Mandriva > 2008.1 > i586 > by-pkgid > 703d980c580707c382b4e43e25965bc5 > files > 11872

php-manual-pt_BR-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="Manual do PHP"
HREF="index.html"><LINK
REL="UP"
TITLE="Migrating from PHP 4 to PHP 5"
HREF="migration5.html"><LINK
REL="PREVIOUS"
TITLE="Migrating from PHP 4 to PHP 5"
HREF="migration5.html"><LINK
REL="NEXT"
TITLE="CLI and CGI"
HREF="migration5.cli-cgi.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"
>Manual do PHP</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="migration5.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Apêndice C. Migrating from PHP 4 to PHP 5</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="migration5.cli-cgi.html"
ACCESSKEY="N"
>Próxima</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="migration5.incompatible"
>Backward Incompatible Changes</A
></H1
><P
>&#13;    Although most existing PHP 4 code should work without changes, you should
    pay attention to the following backward incompatible changes:
   </P
><P
></P
><UL
><LI
><P
>&#13;      There are some <A
HREF="reserved.html#reserved.keywords"
>new reserved
      keywords</A
>.
     </P
></LI
><LI
><P
>&#13;      <A
HREF="function.strrpos.html"
><B
CLASS="function"
>strrpos()</B
></A
> and <A
HREF="function.strripos.html"
><B
CLASS="function"
>strripos()</B
></A
> now use
      the entire string as a needle.
     </P
></LI
><LI
><P
>&#13;      Illegal use of string offsets causes <TT
CLASS="constant"
><B
>E_ERROR</B
></TT
> instead
      of <TT
CLASS="constant"
><B
>E_WARNING</B
></TT
>. An example illegal use is: 
      <TT
CLASS="literal"
>$str = 'abc'; unset($str[0]);</TT
>.
     </P
></LI
><LI
><P
>&#13;      <A
HREF="function.array-merge.html"
><B
CLASS="function"
>array_merge()</B
></A
> was changed to accept only arrays. If a
      non-array variable is passed, a <TT
CLASS="constant"
><B
>E_WARNING</B
></TT
> will be
      thrown for every such parameter. Be careful because your code may start
      emitting <TT
CLASS="constant"
><B
>E_WARNING</B
></TT
> out of the blue.
     </P
></LI
><LI
><P
>&#13;      PATH_TRANSLATED 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 SCRIPT_FILENAME server variable when it is not
      populated by Apache. This change was made to comply with the <A
HREF="http://hoohoo.ncsa.uiuc.edu/cgi/"
TARGET="_top"
>CGI specification</A
>. Please refer to <A
HREF="http://bugs.php.net/23610"
TARGET="_top"
>bug #23610</A
> for further information,
      and see also the <A
HREF="reserved.variables.html#reserved.variables.server"
>&#13;      $_SERVER['PATH_TRANSLATED']</A
> description in the manual. This issue 
      also affects PHP versions &#62;= 4.3.2.
     </P
></LI
><LI
><P
>&#13;      The <TT
CLASS="constant"
><B
>T_ML_COMMENT</B
></TT
> constant is no longer defined by
      the <A
HREF="ref.tokenizer.html"
>Tokenizer</A
> extension. If
      error_reporting is set to <TT
CLASS="constant"
><B
>E_ALL</B
></TT
>, PHP will
      generate a notice. Although the <TT
CLASS="constant"
><B
>T_ML_COMMENT</B
></TT
> was
      never used at all, it was defined in PHP 4. In both PHP 4 and PHP 5
      // and /* */ are resolved as the <TT
CLASS="constant"
><B
>T_COMMENT</B
></TT
>
      constant. However the PHPDoc style comments /** */, which starting PHP
      5 are parsed by PHP, are recognized as <TT
CLASS="constant"
><B
>T_DOC_COMMENT</B
></TT
>. 
     </P
></LI
><LI
><P
>&#13;      $_SERVER should be populated with argc and argv if  <A
HREF="ini.core.html#ini.variables-order"
>variables_order</A
> includes "S". If
      you have specifically configured your system to not create $_SERVER,
      then of course it shouldn't be there. The change was to always make argc
      and argv available in the CLI version regardless of the <A
HREF="ini.core.html#ini.variables-order"
>variables_order</A
> setting. As in,
      the CLI version will now always populate the global $argc and $argv
      variables.
     </P
></LI
><LI
><P
>&#13;      An object with no properties is no longer considered "empty".
     </P
></LI
><LI
><P
>&#13;      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"
>interfaces</A
>) are used.
      Otherwise the behaviour is the old.
     </P
></LI
><LI
><P
>&#13;      <A
HREF="function.get-class.html"
><B
CLASS="function"
>get_class()</B
></A
>, <A
HREF="function.get-parent-class.html"
><B
CLASS="function"
>get_parent_class()</B
></A
>
      and <A
HREF="function.get-class-methods.html"
><B
CLASS="function"
>get_class_methods()</B
></A
> 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
      <A
HREF="function.strtolower.html"
><B
CLASS="function"
>strtolower()</B
></A
>.
     </P
><P
>&#13;      This case sensitivity change also applies to the 
      <A
HREF="language.constants.predefined.html"
>magical predefined 
      constants</A
> <TT
CLASS="constant"
><B
>__CLASS__</B
></TT
>, 
      <TT
CLASS="constant"
><B
>__METHOD__</B
></TT
>, and <TT
CLASS="constant"
><B
>__FUNCTION__</B
></TT
>.
      The values are returned exactly as they're declared (case-sensitive).
     </P
></LI
><LI
><P
>&#13;      <A
HREF="function.ip2long.html"
><B
CLASS="function"
>ip2long()</B
></A
> now returns <TT
CLASS="constant"
><B
>FALSE</B
></TT
> when an invalid IP
      address is passed as argument to the function, and no longer
      <TT
CLASS="literal"
>-1</TT
>.
     </P
></LI
><LI
><P
>&#13;      If there are functions defined in the included file, they can be used in the
      main file independent if they are before <A
HREF="function.return.html"
><B
CLASS="function"
>return()</B
></A
> or after.
      If the file is included twice, PHP 5 issues fatal error because functions
      were already declared, while PHP 4 doesn't complain about it.
      It is recommended to use <A
HREF="function.include-once.html"
><B
CLASS="function"
>include_once()</B
></A
> instead of
      checking if the file was already included and conditionally return inside
      the included file.
     </P
></LI
><LI
><P
>&#13;      <A
HREF="function.include-once.html"
><B
CLASS="function"
>include_once()</B
></A
> and <A
HREF="function.require-once.html"
><B
CLASS="function"
>require_once()</B
></A
>
      first normalize the path of included file on Windows so that including
      A.php and a.php include the file just once.
     </P
></LI
></UL
><P
>&#13;    <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN275835"
></A
><P
><B
>Exemplo C-1. <A
HREF="function.strrpos.html"
><B
CLASS="function"
>strrpos()</B
></A
> and <A
HREF="function.strripos.html"
><B
CLASS="function"
>strripos()</B
></A
> now
      use the entire string as a needle</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />var_dump</font><font color="#007700">(</font><font color="#0000BB">strrpos</font><font color="#007700">(</font><font color="#DD0000">'ABCDEF'</font><font color="#007700">,</font><font color="#DD0000">'DEF'</font><font color="#007700">)); </font><font color="#FF8000">//int(3)<br /><br /></font><font color="#0000BB">var_dump</font><font color="#007700">(</font><font color="#0000BB">strrpos</font><font color="#007700">(</font><font color="#DD0000">'ABCDEF'</font><font color="#007700">,</font><font color="#DD0000">'DAF'</font><font color="#007700">)); </font><font color="#FF8000">//bool(false)<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
   </P
><P
>&#13;    <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN275841"
></A
><P
><B
>Exemplo C-2. An object with no properties is no longer considered "empty"</B
></P
><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">test </font><font color="#007700">{ }<br /></font><font color="#0000BB">$t </font><font color="#007700">= new </font><font color="#0000BB">test</font><font color="#007700">();<br /><br /></font><font color="#0000BB">var_dump</font><font color="#007700">(empty(</font><font color="#0000BB">$t</font><font color="#007700">)); </font><font color="#FF8000">// echo bool(false)<br /><br /></font><font color="#007700">if (</font><font color="#0000BB">$t</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">// Will be executed<br /></font><font color="#007700">}<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
   </P
><P
>&#13;    <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN275845"
></A
><P
><B
>Exemplo C-3. In some cases classes must be declared before used</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /><br /></font><font color="#FF8000">//works with no errors:<br /></font><font color="#0000BB">$a </font><font color="#007700">= new </font><font color="#0000BB">a</font><font color="#007700">();<br />class </font><font color="#0000BB">a </font><font color="#007700">{<br />}<br /><br /><br /></font><font color="#FF8000">//throws an error:<br /></font><font color="#0000BB">$a </font><font color="#007700">= new </font><font color="#0000BB">b</font><font color="#007700">();<br /><br /></font><font color="#0000BB">interface c</font><font color="#007700">{<br />}<br />class </font><font color="#0000BB">b implements c </font><font color="#007700">{<br />} <br /><br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
   </P
></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="migration5.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Principal</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="migration5.cli-cgi.html"
ACCESSKEY="N"
>Próxima</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Migrating from PHP 4 to PHP 5</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="migration5.html"
ACCESSKEY="U"
>Acima</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>CLI and CGI</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>