NYCPHP Meetup

NYPHP.org

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

Daniel Convissor danielc at analysisandsolutions.com
Tue Mar 9 14:52:09 EST 2004


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



More information about the talk mailing list