Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

Ref Class Reference

List of all members.

Public Member Functions

 Ref (&$r)
 type ()
 getClassName ()

Public Attributes

 $obj

Detailed Description

Reference class.

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.

Author:
Laurent Bedubourg <laurent.bedubourg@free.fr>

Definition at line 96 of file Ref.php.


Constructor & Destructor Documentation

Ref::Ref &$  r  ) 
 

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.

Parameters:
mixed $r -- the object or data to reference.

Definition at line 115 of file Ref.php.

References is_ref().


Member Function Documentation

Ref::getClassName  ) 
 

Return the class name of the referenced variable (if object).

Returns:
string (empty if not an object)

Definition at line 139 of file Ref.php.

Ref::type  ) 
 

Retrieve the type or the referenced variable.

Returns:
string

Definition at line 129 of file Ref.php.


Member Data Documentation

Ref::$obj
 

php reference to data.

Definition at line 101 of file Ref.php.


The documentation for this class was generated from the following file:
Generated on Tue Jun 29 23:41:02 2004 for Mediawiki by doxygen 1.3.7