Annotation of embedaddon/php/README.PHP4-TO-PHP5-THIN-CHANGES, revision 1.1.1.1

1.1       misho       1: 1. strrpos() and strripos() now use the entire string as a needle.  Be aware
                      2:    that the existing scripts may no longer work as you expect.
                      3: 
                      4:    EX :
                      5:    <?php
                      6:    var_dump(strrpos("ABCDEF","DEF"));
                      7:    var_dump(strrpos("ABCDEF","DAF"));
                      8:    ?>
                      9: 
                     10:    Will give you different results. The former returns 3 while the latter
                     11:    returns false rather than the position of the last occurrence of 'D'.
                     12:    The same applies to strripos().
                     13: 
                     14: 2. Illegal use of string offsets causes E_ERROR instead of E_WARNING.
                     15: 
                     16:    EX :
                     17:    <?php
                     18:    $a = "foo";
                     19:    unset($a[0][1][2]);
                     20:    ?>
                     21: 
                     22:    Fatal error: Cannot use string offset as an array in ... on line 1
                     23: 
                     24: 3. array_merge() was changed to accept only arrays. If a non-array variable is
                     25:    passed, a E_WARNING will be thrown for every such parameter. Be careful
                     26:    because your code may start emitting E_WARNING out of the blue.
                     27: 
                     28: 4. Be careful when porting from ext/mysql to ext/mysqli. The following
                     29:    functions return NULL when no more data is available in the result set
                     30:    (ext/mysql's functions return FALSE).
                     31: 
                     32:     - mysqli_fetch_row()
                     33:     - mysqli_fetch_array()
                     34:     - mysqli_fetch_assoc()
                     35: 
                     36: 5. PATH_TRANSLATED server variable is no longer set implicitly under
                     37:    Apache2 SAPI in contrast to the situation in PHP 4, where it is set to the
                     38:    same value as the SCRIPT_FILENAME server variable when it is not populated
                     39:    by Apache.  This change was made to comply with the CGI specification.
                     40:    Please refer to bug #23610 for further information.
                     41: 
                     42: 6. Starting PHP 5.0.0 the T_ML_CONSTANT constant is no longer defined by the
                     43:    ext/tokenizer extension. If error_reporting is set to E_ALL notices will
                     44:    be produced. Instead of T_ML_CONSTANT for /* */ the T_COMMENT constant 
                     45:    is used, thus both // and /* */ are resolved as the T_COMMENT constant.
                     46:    However the PHPDoc style comments /** */ ,which starting PHP 5 are parsed
                     47:    by PHP, are recongnized as T_DOC_COMMENT.
                     48: 
                     49: 7. $_SERVER should be populated with argc and argv if variables_order
                     50:    includes "S".  If you have specifically configured your system to not
                     51:    create $_SERVER, then of course it shouldn't be there.  The change was to
                     52:    always make argc and argv available in the CLI version regardless of the
                     53:    variables_order setting.  As in, the CLI version will now always populate
                     54:    the global $argc and $argv variables.
                     55: 
                     56: 8. In some cases classes must be declared before used. It only happens only
                     57:    if some of the new features of PHP 5 are used. Otherwise the behaviour is
                     58:    the old.
                     59:    Example 1 (works with no errors):
                     60:    <?php
                     61:    $a = new a();
                     62:    class a {
                     63:    }
                     64:    ?>
                     65:  
                     66:    Example 2 (throws an error):
                     67:    <?php 
                     68:    $a = new a();
                     69:    interface b{
                     70:    }
                     71:    class a implements b {
                     72:    } 
                     73:    ?>
                     74: 
                     75:    Output (example 2) :
                     76:    Fatal error: Class 'a' not found in /tmp/cl.php on line 2
                     77: 
                     78: 9. get_class() starting PHP 5 returns the name of the class as it was
                     79:    declared which may lead to problems in older scripts that rely on
                     80:    the previous behaviour - the class name is lowercased. Expect the
                     81:    same behaviour from get_parent_class() when applicable.
                     82:    Example :
                     83:    <?php
                     84:    class FooBar {
                     85:    }
                     86:    class ExtFooBar extends FooBar{}
                     87:    $a = new FooBar();
                     88:    var_dump(get_class($a), get_parent_class($a));
                     89:    ?>
                     90: 
                     91:    Output (PHP 4):
                     92:    string(6) "foobar"
                     93:    string(9) "extfoobar"
                     94: 
                     95:    Output (PHP 5):
                     96:    string(6) "FooBar"
                     97:    string(9) "ExtFooBar"
                     98:    ----------------------------------------------------------------------
                     99:    Example code that will break :
                    100:    //....
                    101:    function someMethod($p) {
                    102:      if (get_class($p) != 'helpingclass') {
                    103:        return FALSE;
                    104:      }
                    105:      //...
                    106:    }
                    107:    //...
                    108:    Possible solution is to search for get_class() and get_parent_class() in
                    109:    all your scripts and use strtolower().
                    110: 
                    111: 10. get_class_methods() returns the names of the methods of a class as they
                    112:    declared. In PHP4 the names are all lowercased.
                    113:    Example code :
                    114:    <?php
                    115:    class Foo{
                    116:      function doFoo(){}
                    117:      function hasFoo(){}
                    118:    }
                    119:    var_dump(get_class_methods("Foo")); 
                    120:    ?>
                    121:    Output (PHP4):
                    122:    array(2) {
                    123:      [0]=>
                    124:      string(5) "dofoo"
                    125:      [1]=>
                    126:      string(6) "hasfoo"
                    127:    }
                    128:    Output (PHP5):
                    129:    array(2) {
                    130:      [0]=>
                    131:      string(5) "doFoo"
                    132:      [1]=>
                    133:      string(6) "hasFoo"
                    134:    }
                    135: 
                    136: 11. Assignment $this is impossible. Starting PHP 5.0.0 $this has special
                    137:     meaning in class methods and is recognized by the PHP parser. The latter
                    138:     will generate a parse error when assignment to $this is found
                    139:     Example code :
                    140:     <?php
                    141:     class Foo {
                    142:       function assignNew($obj) {
                    143:         $this = $obj;
                    144:       }
                    145:     }
                    146:     $a = new Foo();
                    147:     $b = new Foo();
                    148:     $a->assignNew($b);
                    149:     echo "I was executed\n";
                    150:     ?>
                    151:     Output (PHP 4):
                    152:     I was executed
                    153:     Output (PHP 5):
                    154:     PHP Fatal error:  Cannot re-assign $this in /tmp/this_ex.php on line 4
                    155: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>