Re: PEAR CS poll
| From: | Alan Knowles | Date: | Sat, 09 Oct 2004 01:05:21 +0000 |
| Subject: | Re: PEAR CS poll | ||
| References: | 1 2 3 4 5 6 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-33728@lists.php.net to get a copy of this message | ||
$modifystuff =& $this->path->to->extremely->rare->array;
$modifystuff[] = 'test';
It still has uses.. &PEAR::getStaticProperty() will still need it..
Regards
Alan
Klaus Guenther wrote:
Stefan Walk wrote:On Sat, Oct 09, 2004 at 12:06:45AM +0200, Klaus Guenther wrote:So when you do $foo = new Class; $bar = $foo; $bar->test = true; then I suppose $foo->test == true Just the same as if the =& operater were used. If this is the case, I personally don't see that much use in PEAR packages for the =& operator as implemented in php5. It is asking for people to accidentally unset an object that they might indeed still need (by unsetting the one variable, they unset all others that point to the same object). Of course, there must be valid uses for it, but they are not very obvious, imho. KlausWhat's the difference? Isn't the php5 default to pass by reference?Well, in a way you pass a "handle" by copy. So you copy the handle, but both handles point to the same object. The difference is: $foo = new Class; $bar =& $foo; $bar = "bar"; var_dump($foo) will say "bar". Without the &, it will still be an object of the class Class. But as you only copy a handle, both $foo and $bar point to the same object.