Public Member Functions | |
Ref (&$r) | |
type () | |
getClassName () | |
Public Attributes | |
$obj |
There's a lot to say about references in PHP. The main problem come from the fact that until ZendEngine2, objects are copied if not referenced.
This class helps keeping references to objects even while modifying arrays.
Example :
If an array stores objects, using array_values will copy its elements.
If an array stores Ref objects referencing real objects, array_values copy Ref objects but these copies still reference the source object.
Until ZendEngine2, it is safer to use Ref objects in stead of object references.
<?php
$a = new Foo('bar'); $v = new Vector(); $v->push(Ref($a));
?>
Important :
This object will have no meaning in php 4.4 as PHP will then use references everywhere objects are involved.
Definition at line 96 of file Ref.php.
|
Reference constructor. Important: If $r is a reference, the new reference will just be a copy of the parameter. A Ref cannot reference a Ref.
Definition at line 115 of file Ref.php. References is_ref(). |
|
Return the class name of the referenced variable (if object).
|
|
Retrieve the type or the referenced variable.
|
|
php reference to data. |