Re: Use of {} with member.

From: Date: Thu, 29 Jan 2015 21:43:06 +0000
Subject: Re: Use of {} with member.
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-81389@lists.php.net to get a copy of this message
Hi, On Thu, Jan 29, 2015 at 11:32 PM, Yasuo Ohgaki <yohgaki@ohgaki.net> wrote: > 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 > Is somebody actually recommending the latter form? I'm surprised that it even works ... that should be a syntax error IMO. Cheers, Andrey.

« previous php.internals (#81389) next »