Re: Unexpected behavior of $this->$propertyName[...]
| From: | Paul Biggar | Date: | Thu, 15 Jan 2009 19:35:37 +0000 |
| Subject: | Re: Unexpected behavior of $this->$propertyName[...] | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-42646@lists.php.net to get a copy of this message | ||
On Thu, Jan 15, 2009 at 7:24 PM, Robert Lemke <robert@typo3.org> wrote:
> Dear internals,
>
> please consider the following code executed with PHP 5.3alpha3:
I suspect neither bug nor feature. I think you expect that
$this->$propertyName['bar']
is the same as:
($this->$propertyName)['bar']
but in fact it is:
$this->($propertyName['bar'])
So in your example, 'bar' is the string index 0 for "foo"[0], hence
'f'.
> Is this a bug or missing feature?
It has been pointed out before that one should be able to index an
expression, but currently PHP can only index variables. Personally, it
seems like a bug, but I'm not sure whether or not there's consensus.
Paul
--
Paul Biggar
paul.biggar@gmail.com