How has the use of references changed between PHP4 and PHP5, particularly in object-oriented programming?

In PHP4, references were commonly used as a way to pass variables by reference, allowing for more efficient memory usage and avoiding unnecessary copying of data. However, in PHP5, the introduction of object-oriented programming brought a shift towards using objects and references to objects instead of references to variables. This change improved code readability and maintainability in object-oriented programming.

// PHP4 style using references with variables
$var = 5;
$ref = &$var;

// PHP5 style using objects and references to objects
class MyClass {
    public $prop;
}

$obj = new MyClass();
$obj->prop = 5;

$ref = $obj;