Use of {} with member.
| From: | Yasuo Ohgaki | Date: | Thu, 29 Jan 2015 21:32:20 +0000 |
| Subject: | Use of {} with member. | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-81388@lists.php.net to get a copy of this message | ||
Hi all,
I came across with bug #68947 https://bugs.php.net/bug.php?id=68947
and realized small inconsistency.
http://3v4l.org/ldZKl
$obj->${array[$key]}; // Syntax error
$obj->{$array[$key]}; // Works
$obj->${key}; // E_NOTICE. Does not work
$obj->{$key}; // Works
echo "${array[$key]}"; // Works
echo "{$array[$key]}"; // Works
Of course, script/string parsing aren't the same. Are there technical
reasons
why ${value} is not allowed? If there are, we may encourage
echo "{$array[$key]}"; // Works
rather than
echo "${array[$key]}"; // Works
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net