Quick variable duplication?
Posted: Sun May 10, 2009 10:25 am
Hi everyone,
I've seen this crop up a few times now and would just like to clarify what's going on with it:
Does this mean that $GLOBALS['varname'] is the same as $varname, and there is only one instance of classname (assuming $varname is in the global scope)?
So taking a slightly different approach:
Does this mean that $var1 and $var2 are the same value, but declares both variables for separate usage? I.e. are you effectively duplicating the variable with the added '$var2 = ' ? (Come to think of it, that doesn't give a parse error does it!?). So going one step further, could you declare as many vars as you want like this, e.g. $var1 = $var2 = $var3 (etc) = 'value' ?
Thanks, Ben
I've seen this crop up a few times now and would just like to clarify what's going on with it:
Code: Select all
$varname = $GLOBALS['varname'] = new classname;So taking a slightly different approach:
Code: Select all
$var1 = $var2 = 'anything';Thanks, Ben