Unexpected behavior of $this->$propertyName[...]
| From: | Robert Lemke | Date: | Thu, 15 Jan 2009 19:24:01 +0000 |
| Subject: | Unexpected behavior of $this->$propertyName[...] | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-42645@lists.php.net to get a copy of this message | ||
Dear internals,
please consider the following code executed with PHP 5.3alpha3:
<?php
class Foo {
protected $foo = array('bar' => 'baz');
public function test() {
$propertyName = 'foo';
var_dump(isset($this->foo['bar']));
var_dump(isset($this->$propertyName['bar']));
}
}
$object = new Foo;
$object->test();
?>
Expected output:
array
'foo' =>
array
'bar' => string 'quux' (length=4)
Actual output:
array
'foo' =>
array
'bar' => string 'baz' (length=3)
'f' => string 'quux' (length=4)
Is this a bug or missing feature?
Cheers,
robert