What are the differences in handling object references between PHP 4 and PHP 5 versions?
In PHP 4, object references were handled differently compared to PHP 5. In PHP 4, object assignment was done by value, meaning that changes to one object would not affect another object it was assigned to. In PHP 5, object assignment is done by reference, so changes to one object will affect all references to that object. To ensure compatibility with PHP 5, it is important to use the "&" symbol when assigning object references in PHP 4.
// PHP 4
$object1 = new MyClass();
$object2 = $object1; // $object2 is a copy of $object1 in PHP 4
// PHP 5
$object1 = new MyClass();
$object2 = &$object1; // $object2 is a reference to $object1 in PHP 5