[Sussex] PHP4 - pointers and updates to a class

Colin Tuckley colin at tuckley.org
Thu Mar 24 21:19:21 UTC 2005


Steve Dobson wrote:

>     I want would like each node to have a reference (pointer) to 
>     its parent.

In a function you specify call by reference by declaring the function as:

	function fred(&$var) {...

Note the & (ampersand) in the formal parameter.

You can also assign by reference:

	$x = 10;
	$y = &$x;
	$y++;
	echo $x;
	echo $y;

This prints 11 twice since $y now points to $x.

Colin

-- 
Colin Tuckley      |  colin at tuckley.org  |  PGP/GnuPG Key Id
+44(0)1903 236872  |  +44(0)7799 143369  |     0x1B3045CE

 "Heisenberg may have slept here"




More information about the Sussex mailing list