|
Posted by Michael Fesser on 09/28/07 08:15
..oO(Summercool)
>so many places, including the book PHP in a Nutshell, p. 80, it says:
>
>$a =& $b # set $a to reference $b
>
>if $a reference $b, then while you can say $b =1, you can't really
>say $a = 1. you need to say *($a) = 1 as in C or C++. Referencing
>must be coupled with dereferencing, and PHP is not doing the
>dereferencing, so why is it call referencing in the first place?
There's nothing to dereference. A reference is not a pointer.
>(don't tell me PHP automatically dereference... as it will be really
>weird).
>
>and i think in the PHP group, people say "reference" to mean "alias".
Exactly. It's just another name for the same value, like a hard link in
a *nix file system.
>2) There are actually two "reference" methods (as in my previous post
>topic). One is $obj1 = $obj2, and it works the same as in Java,
>Python, and Ruby (maybe in Perl too?). The other behavior is the $a
>=& $b and it is different, and why is it still called "reference"?
The first is implicitly done by the PHP 5 compiler when working with
objects, the second is explicitly done by the programmer as needed.
Micha
[Back to original message]
|