Re: Re: reference variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux