Location: PHPKode > scripts > phpGlobalRef > phpglobalref/phpglobalref.php
<?php

/** Easy Object-Handling with the GlobalArray.
* Adds reference of Objects in the GlobalArray so any other Class can use this Object
* without recreating it.
* @note Use $Ref = &getRef("NAME"); to get a real reference(&)!
* @author Maurice Ullrich
* @date 2003
*/
class phpGlobalRef{
var $GlobalRefVar;

	function phpGlobalRef()
	{
		$this->GlobalRefVar = "GlobalRef";	// Name of Arraykey in the GlobalArray
	}

/** Adds a reference to the GlobalArray.
* @param $Object Object. The Object that should be add to the GlobalArray
* @param $Name String. The Name of the Object.
*/
	function addRef(&$Object, $Name)
	{
		$GLOBALS[$this->GlobalRefVar][$Name] = &$Object;
	}

/** Return the reference from the GlobalArray.
* @param $Name String.  The Name of the Object.
* @return Object. Returns the Reference of the Object with the name $Name.
*/
	function &getRef($Name)
	{
		$Object = &$GLOBALS[$this->GlobalRefVar][$Name];
		return $Object;
	}

/** Returns a list of Names from the GlobalArray.
* Return a list names from all Objects that are placed in the phpGlobalRef-Part of GlobalArray.
* @return Array. List of all Objectnames.
*/
	function getRefList()
	{
		foreach($GLOBALS[$this->GlobalRefVar] as $key => $elem) {
			$Reflist[] = $key;
		}
		return $Reflist;
	}

/** Delete a reference of an Object.
* @param $Name String. Name of Object.
*/
	function deleteRef($Name)
	{
		unset($GLOBALS[$this->GlobalRefVar][$Name]);
	}

}
?>
Return current item: phpGlobalRef