158a52b16SAndrey Hristov1. strrpos() and strripos() now use the entire string as a needle.  Be aware
258a52b16SAndrey Hristov   that the existing scripts may no longer work as you expect.
361e6cd2aSMoriyoshi Koizumi
41fa74586SAndrey Hristov   EX :
51fa74586SAndrey Hristov   <?php
61fa74586SAndrey Hristov   var_dump(strrpos("ABCDEF","DEF"));
71fa74586SAndrey Hristov   var_dump(strrpos("ABCDEF","DAF"));
81fa74586SAndrey Hristov   ?>
932f41d17SAndrey Hristov
1061e6cd2aSMoriyoshi Koizumi   Will give you different results. The former returns 3 while the latter
1161e6cd2aSMoriyoshi Koizumi   returns false rather than the position of the last occurrence of 'D'.
1261e6cd2aSMoriyoshi Koizumi   The same applies to strripos().
1361e6cd2aSMoriyoshi Koizumi
1461e6cd2aSMoriyoshi Koizumi2. Illegal use of string offsets causes E_ERROR instead of E_WARNING.
1561e6cd2aSMoriyoshi Koizumi
1632f41d17SAndrey Hristov   EX :
1761e6cd2aSMoriyoshi Koizumi   <?php
1861e6cd2aSMoriyoshi Koizumi   $a = "foo";
1961e6cd2aSMoriyoshi Koizumi   unset($a[0][1][2]);
2061e6cd2aSMoriyoshi Koizumi   ?>
2161e6cd2aSMoriyoshi Koizumi
2261e6cd2aSMoriyoshi Koizumi   Fatal error: Cannot use string offset as an array in ... on line 1
2332f41d17SAndrey Hristov
2461e6cd2aSMoriyoshi Koizumi3. array_merge() was changed to accept only arrays. If a non-array variable is
2561e6cd2aSMoriyoshi Koizumi   passed, a E_WARNING will be thrown for every such parameter. Be careful
2661e6cd2aSMoriyoshi Koizumi   because your code may start emitting E_WARNING out of the blue.
2732f41d17SAndrey Hristov
2861e6cd2aSMoriyoshi Koizumi4. Be careful when porting from ext/mysql to ext/mysqli. The following
2961e6cd2aSMoriyoshi Koizumi   functions return NULL when no more data is available in the result set
3061e6cd2aSMoriyoshi Koizumi   (ext/mysql's functions return FALSE).
3161e6cd2aSMoriyoshi Koizumi
3261e6cd2aSMoriyoshi Koizumi    - mysqli_fetch_row()
3361e6cd2aSMoriyoshi Koizumi    - mysqli_fetch_array()
3461e6cd2aSMoriyoshi Koizumi    - mysqli_fetch_assoc()
355ce35b82SMoriyoshi Koizumi
365ce35b82SMoriyoshi Koizumi5. PATH_TRANSLATED server variable is no longer set implicitly under
37f4983c0dSfoobar   Apache2 SAPI in contrast to the situation in PHP 4, where it is set to the
385ce35b82SMoriyoshi Koizumi   same value as the SCRIPT_FILENAME server variable when it is not populated
395ce35b82SMoriyoshi Koizumi   by Apache.  This change was made to comply with the CGI specification.
405ce35b82SMoriyoshi Koizumi   Please refer to bug #23610 for further information.
4161e6cd2aSMoriyoshi Koizumi
427baf31fcSAndrey Hristov6. Starting PHP 5.0.0 the T_ML_CONSTANT constant is no longer defined by the
437baf31fcSAndrey Hristov   ext/tokenizer extension. If error_reporting is set to E_ALL notices will
447baf31fcSAndrey Hristov   be produced. Instead of T_ML_CONSTANT for /* */ the T_COMMENT constant
457baf31fcSAndrey Hristov   is used, thus both // and /* */ are resolved as the T_COMMENT constant.
463bf293ffSAndi Gutmans   However the PHPDoc style comments /** */ ,which starting PHP 5 are parsed
47d5d2d9efSAndrey Hristov   by PHP, are recongnized as T_DOC_COMMENT.
481a559924SAndrey Hristov
490fa195d2SAndrey Hristov7. $_SERVER should be populated with argc and argv if variables_order
500fa195d2SAndrey Hristov   includes "S".  If you have specifically configured your system to not
510fa195d2SAndrey Hristov   create $_SERVER, then of course it shouldn't be there.  The change was to
520fa195d2SAndrey Hristov   always make argc and argv available in the CLI version regardless of the
530fa195d2SAndrey Hristov   variables_order setting.  As in, the CLI version will now always populate
540fa195d2SAndrey Hristov   the global $argc and $argv variables.
5585de35e4SAndrey Hristov
5658a52b16SAndrey Hristov8. In some cases classes must be declared before used. It only happens only
5758a52b16SAndrey Hristov   if some of the new features of PHP 5 are used. Otherwise the behaviour is
5858a52b16SAndrey Hristov   the old.
5958a52b16SAndrey Hristov   Example 1 (works with no errors):
6085de35e4SAndrey Hristov   <?php
6158a52b16SAndrey Hristov   $a = new a();
6258a52b16SAndrey Hristov   class a {
6358a52b16SAndrey Hristov   }
6458a52b16SAndrey Hristov   ?>
6558a52b16SAndrey Hristov
6658a52b16SAndrey Hristov   Example 2 (throws an error):
6758a52b16SAndrey Hristov   <?php
6858a52b16SAndrey Hristov   $a = new a();
6958a52b16SAndrey Hristov   interface b{
7058a52b16SAndrey Hristov   }
7158a52b16SAndrey Hristov   class a implements b {
7258a52b16SAndrey Hristov   }
7358a52b16SAndrey Hristov   ?>
7458a52b16SAndrey Hristov
7558a52b16SAndrey Hristov   Output (example 2) :
7658a52b16SAndrey Hristov   Fatal error: Class 'a' not found in /tmp/cl.php on line 2
7785de35e4SAndrey Hristov
7858a52b16SAndrey Hristov9. get_class() starting PHP 5 returns the name of the class as it was
7958a52b16SAndrey Hristov   declared which may lead to problems in older scripts that rely on
80*b8b1b359SAndrey Hristov   the previous behaviour - the class name is lowercased. Expect the
81*b8b1b359SAndrey Hristov   same behaviour from get_parent_class() when applicable.
8258a52b16SAndrey Hristov   Example :
8358a52b16SAndrey Hristov   <?php
8458a52b16SAndrey Hristov   class FooBar {
8585de35e4SAndrey Hristov   }
86*b8b1b359SAndrey Hristov   class ExtFooBar extends FooBar{}
8758a52b16SAndrey Hristov   $a = new FooBar();
88*b8b1b359SAndrey Hristov   var_dump(get_class($a), get_parent_class($a));
8985de35e4SAndrey Hristov   ?>
9058a52b16SAndrey Hristov
9158a52b16SAndrey Hristov   Output (PHP 4):
9258a52b16SAndrey Hristov   string(6) "foobar"
93*b8b1b359SAndrey Hristov   string(9) "extfoobar"
9458a52b16SAndrey Hristov
9558a52b16SAndrey Hristov   Output (PHP 5):
9658a52b16SAndrey Hristov   string(6) "FooBar"
97*b8b1b359SAndrey Hristov   string(9) "ExtFooBar"
9858a52b16SAndrey Hristov   ----------------------------------------------------------------------
9958a52b16SAndrey Hristov   Example code that will break :
10058a52b16SAndrey Hristov   //....
10158a52b16SAndrey Hristov   function someMethod($p) {
10258a52b16SAndrey Hristov     if (get_class($p) != 'helpingclass') {
10358a52b16SAndrey Hristov       return FALSE;
10458a52b16SAndrey Hristov     }
10558a52b16SAndrey Hristov     //...
10658a52b16SAndrey Hristov   }
10758a52b16SAndrey Hristov   //...
108*b8b1b359SAndrey Hristov   Possible solution is to search for get_class() and get_parent_class() in
109*b8b1b359SAndrey Hristov   all your scripts and use strtolower().
110*b8b1b359SAndrey Hristov
111*b8b1b359SAndrey Hristov10. get_class_methods() returns the names of the methods of a class as they
112*b8b1b359SAndrey Hristov   declared. In PHP4 the names are all lowercased.
113*b8b1b359SAndrey Hristov   Example code :
114*b8b1b359SAndrey Hristov   <?php
115*b8b1b359SAndrey Hristov   class Foo{
116*b8b1b359SAndrey Hristov     function doFoo(){}
117*b8b1b359SAndrey Hristov     function hasFoo(){}
118*b8b1b359SAndrey Hristov   }
119*b8b1b359SAndrey Hristov   var_dump(get_class_methods("Foo"));
120*b8b1b359SAndrey Hristov   ?>
121*b8b1b359SAndrey Hristov   Output (PHP4):
122*b8b1b359SAndrey Hristov   array(2) {
123*b8b1b359SAndrey Hristov     [0]=>
124*b8b1b359SAndrey Hristov     string(5) "dofoo"
125*b8b1b359SAndrey Hristov     [1]=>
126*b8b1b359SAndrey Hristov     string(6) "hasfoo"
127*b8b1b359SAndrey Hristov   }
128*b8b1b359SAndrey Hristov   Output (PHP5):
129*b8b1b359SAndrey Hristov   array(2) {
130*b8b1b359SAndrey Hristov     [0]=>
131*b8b1b359SAndrey Hristov     string(5) "doFoo"
132*b8b1b359SAndrey Hristov     [1]=>
133*b8b1b359SAndrey Hristov     string(6) "hasFoo"
134*b8b1b359SAndrey Hristov   }
135*b8b1b359SAndrey Hristov
136*b8b1b359SAndrey Hristov11. Assignment $this is impossible. Starting PHP 5.0.0 $this has special
137*b8b1b359SAndrey Hristov    meaning in class methods and is recognized by the PHP parser. The latter
138*b8b1b359SAndrey Hristov    will generate a parse error when assignment to $this is found
139*b8b1b359SAndrey Hristov    Example code :
140*b8b1b359SAndrey Hristov    <?php
141*b8b1b359SAndrey Hristov    class Foo {
142*b8b1b359SAndrey Hristov      function assignNew($obj) {
143*b8b1b359SAndrey Hristov        $this = $obj;
144*b8b1b359SAndrey Hristov      }
145*b8b1b359SAndrey Hristov    }
146*b8b1b359SAndrey Hristov    $a = new Foo();
147*b8b1b359SAndrey Hristov    $b = new Foo();
148*b8b1b359SAndrey Hristov    $a->assignNew($b);
149*b8b1b359SAndrey Hristov    echo "I was executed\n";
150*b8b1b359SAndrey Hristov    ?>
151*b8b1b359SAndrey Hristov    Output (PHP 4):
152*b8b1b359SAndrey Hristov    I was executed
153*b8b1b359SAndrey Hristov    Output (PHP 5):
154*b8b1b359SAndrey Hristov    PHP Fatal error:  Cannot re-assign $this in /tmp/this_ex.php on line 4
15558a52b16SAndrey Hristov
156