Difference between revisions of "ObjectsAndRefs"
From Hashphp.org
Line 63: | Line 63: | ||
</table> | </table> | ||
+ | |||
+ | |||
+ | ==Notes== | ||
+ | {{Reflist}} |
Revision as of 15:52, 26 July 2011
This page attempts to provide a visual guide to how objects - and references to them - work in PHP 5.0 and later.
class SimpleClass { } $instance = new SimpleClass(); |
|
The above code creates a new class, SimpleClass, with no properties or methods. It then creates a new instance of this class and attaches it to the variable named '$instance'. Because objects are "special" [1] in PHP5, the relationship between the variable '$instance' and the object inside it is not as direct as you might be expecting... | |
$assigned = $instance; | |
Explain the code here | |
$instance->var = '$assigned will have this value as well'; | |
Explain the code here | |
$reference =& $instance; | |
Explain the code here | |
$instance = null; | |
Explain the code here |