Re: Weird.
| From: | Zeev Suraski | Date: | Wed, 14 Jan 2004 12:02:59 +0000 |
| Subject: | Re: Weird. | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-7090@lists.php.net to get a copy of this message | ||
At 11:33 14/01/2004, John Coggeshall wrote:
I know that this issue to some extent or another has been brought up before, but I just wanted to make sure that this is really how things are supposed to work... Apparently the statements setting B C and D are all equivalent. This could be absolutely bogus, but I thought maybe someone could explain briefly why if it is :) John <?phpI don't see anything odd in here. All of the assignments, except for the first one ('A'), assign to $this->"" (because $myvar, ${'myvar'} (which is the same as $myvar) and ${'$myvar'} (which is basically $"") are all non existent variables which implicitly evaluate to "". Try to turn on E_ALL, it should give you some insight... Zeevclass weird {var $myvar;function __construct() {$this->myvar = "A"; $this->$myvar = "B"; $this->${'myvar'} = "C"; $this->${'$myvar'} = "D";echo 'this->myvar: '.$this->myvar."\n"; echo 'this->$myvar: '.$this->$myvar."\n"; echo 'this->${\'myvar\'}: '.$this->${'myvar'}."\n"; echo 'this->${\'$myvar\'}: '.$this->${'$myvar'}."\n"; echo 'this->$$$$$$$myvar: '.$this->$$$$$$$myvar."\n"; echo 'this->$$$$$$${\'$$$myvar\'}: ' . $this->$$$$$$${'$$$myvar'}."\n";} }?>