[thelist] PHP 4 to PHP 5

Rick den Haan rick.denhaan at gmail.com
Tue Mar 6 06:14:02 CST 2007

Paul Bennett wrote:
> Hi all,
> Apart from the Object Model changes, is anyone aware of
> other issues arising from migrating from PHP 4x to PHP 5?
> (IE: Changes in function returns, how some functions work
> etc)
> Paul

One thing that annoyed me quite severely when my hosting party switched from
4 to 5 (unannounced!) was the fact that PHP 5 doesn't copy variables, but
references them. E.g.:

In PHP 4:
$foo = 'bar';
$bar = $foo;
$bar = 'foo';
echo $foo;
// 'bar'

In PHP 5:
$foo = 'bar';
$bar = $foo;
$bar = 'foo';
echo $foo;
// 'foo'

So the $bar = $foo line in PHP 5 has the same effect as $bar =& $foo would
have in PHP 4. This default behavior took a little getting used to.

See here for more info:


More information about the thelist mailing list