NYCPHP Meetup

NYPHP.org

[nycphp-talk] var_dump says "&object(myobj)(10)"

Allen Shaw ashaw at iifwp.org
Tue Mar 9 15:15:17 EST 2004


Thanks.  Actually, I thought it was something like that, but without knowing
more, do you have any guess as to why changing register_globals would affect
whether it gets added as a reference or not?

----- Original Message ----- 
From: "Daniel Convissor" <danielc at analysisandsolutions.com>
To: "NYPHP Talk" <talk at lists.nyphp.org>
Sent: Tuesday, March 09, 2004 2:52 PM
Subject: Re: [nycphp-talk] var_dump says "&object(myobj)(10)"


> On Tue, Mar 09, 2004 at 02:40:22PM -0500, Allen Shaw wrote:
> >
> > With register_globals=off, the object $myobj is listed with an
ampersand,
> > like so:
>
> They both contained the same output.
>
>
> > Can anyone tell me what that ampersand is?
>
> Ampersands refer to references.  Example:
>
> <?php
> $x['a'] = 'one';
> $x['b'] =& $x['a'];
> $x['c'] = 'three';
>
> var_dump($x);
>
> $x['a'] = 'two';
>
> var_dump($x);
> ?>
>
> Output:
>
> array(3) {
>   ["a"]=>
>   &string(3) "one"
>   ["b"]=>
>   &string(3) "one"
>   ["c"]=>
>   string(5) "three"
> }
> array(3) {
>   ["a"]=>
>   &string(3) "two"
>   ["b"]=>
>   &string(3) "two"
>   ["c"]=>
>   string(5) "three"
> }
>
> Notice how I changed the value of b by changing the value of a.
>
> --Dan
>
> -- 
>  T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
>             data intensive web and database programming
>                 http://www.AnalysisAndSolutions.com/
>  4015 7th Ave #4, Brooklyn NY 11232  v: 718-854-0335 f: 718-854-0409
> _______________________________________________
> talk mailing list
> talk at lists.nyphp.org
> http://lists.nyphp.org/mailman/listinfo/talk




More information about the talk mailing list