Re: Use of {} with member.

From: Date: Thu, 29 Jan 2015 23:51:13 +0000
Subject: Re: Use of {} with member.
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-81394@lists.php.net to get a copy of this message
On 01/29/2015 01:32 PM, Yasuo Ohgaki 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 That all seems expected to me. The original point of that bug report is the BC break due to the uniform variable rfc. The change makes sense, but just for the record, I have installed about 10 popular, and a couple of not-so-popular, PHP apps and tested them on PHP 7 over the past week and this was the only BC break that affected that set of 10 apps. See: https://github.com/rlerdorf/avalon/commit/18847d0fe65381977397271c79e04dde72ef86f8 It is listed as a bullet point in a sea of other bullet points in the UPGRADING file: . Indirect variable, property and method references are now interpreted with left-to-right semantics. See details in: https://wiki.php.net/rfc/uniform_variable_syntax#semantic_differences_in_existing_syntax But we probably need a section devoted to BC breaks that includes some real-world code examples. -Rasmus

Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
« previous php.internals (#81394) next »