Re: Re: reference variables

From: Date: Fri, 22 May 2009 14:57:09 +0000
Subject: Re: Re: reference variables
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-292958@lists.php.net to get a copy of this message
kranthi wrote: > thank you for the reply. > > i had a small misunderstanding regarding variable reference...now its clear > > but.. > > the output of > > <?php > $x = 1; > $a1 = array(&$x); > var_dump($a1); > ?> > > is > array(1) { > [0]=> &int(1) > } > > while for > > <?php > $x = 1; > $a1 = array(&$x); > var_dump($a1[0]); > ?> > > it is > > int(1) > > can u tell me what & signifies here?? > In the first instance you are var_dumping the entire array so it shows the structure/values of the array elements thus showing a reference to a var that is int(1). In the second instance you are var_dumping a specific var so you get the value of the var int(1). I'm not sure if there is a reason that it doesn't show that it is a reference, but the same is true here: $x = 1; $y =& $x; var_dump($y); int(1) -- Thanks! -Shawn http://www.spidean.com

« previous php.general (#292958) next »