I’m confused about the concept of variable in PHP.
As far as I know, a variable in PHP has a name ($p
) and a value ('Carlo'
).
$p
has an associated entry in symbol table, such an entry actually points to the memory area where the variable’s value is stored (i.e. the string 'Carlo'
).
Consider the following:
$n =& $p
$n
basically is an alias of $p
therefore it points to the memory area where $p
points to.
From an “under the hood” viewpoint, does the PHP interpreter create a new entry in symbol table for $n
or since it is an alias doesn’t have its own symbol table’s entry ?
Btw, suppose to define class Alpha
with its properties and methods. Then does $c = new Alpha
actually return a “reference” into the $c
variable, in other words is $c
value a reference in memory to an instance of class Alpha
?