Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81393 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29757 invoked from network); 29 Jan 2015 23:01:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Jan 2015 23:01:39 -0000 Authentication-Results: pb1.pair.com header.from=narf@devilix.net; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=narf@devilix.net; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain devilix.net designates 209.85.218.48 as permitted sender) X-PHP-List-Original-Sender: narf@devilix.net X-Host-Fingerprint: 209.85.218.48 mail-oi0-f48.google.com Received: from [209.85.218.48] ([209.85.218.48:60701] helo=mail-oi0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EF/32-16616-1DBBAC45 for ; Thu, 29 Jan 2015 18:01:38 -0500 Received: by mail-oi0-f48.google.com with SMTP id v63so32063540oia.7 for ; Thu, 29 Jan 2015 15:01:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=devilix.net; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=quSqkXVyUqGBHwfsGVSPIqRIT+6WzrS+FILwEoNRBgk=; b=n+9wyY0LcBGmueHmv5JB1T1QvoPlSnulTbIT1blTozzuvlXhjyhVV+AnP+3kHWTq1V XkmcQun7S8AjvMNMVwuukuggDPUx6o34DmIt6BjUcRxyYBXFDIho8NqyBDAQqihKA+Xa OjZfgGLxR3hEzlhulS+SLrKep0qmVQL6iRt7E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=quSqkXVyUqGBHwfsGVSPIqRIT+6WzrS+FILwEoNRBgk=; b=Uu4vRBhnvugxoy5HyW+uW2lACFIFGmpvCmQEZA8zYp9jeGzXwsvudsQ/EUa20DEea1 WqeaxnLwUZZceLHLB1KE4JXXMK2GkPJ6GPPHpMnaZVcWFmJ1dl/jMcCgq6jGrFsb8N6t 6qwL7qhLbOpLN2SCJ2nNwmzKz4cjGgBXTDsfGQS9MADKn0Ezag84xUi7lgDFWH5obfOl Kx5BillbD/g4nqgtXMnTE7ebhuhLOwcEiaorludfHeGr+mWChhLubchwT8lc7GjxO6nL NhERs8wzvXJRipCNKmNo8DdrYMuPWD0VelMDwd8XdQfRFCbuWohY411apmz8fm4IvT1a YLEw== X-Gm-Message-State: ALoCoQlm4OfA1dzbNbrJm4LTsjYNroCSZT1S8tF9qqasbFRorwvYAcrubFKOpkJRXROTdRgAP/Xq MIME-Version: 1.0 X-Received: by 10.202.169.208 with SMTP id s199mr1875644oie.21.1422572494626; Thu, 29 Jan 2015 15:01:34 -0800 (PST) Received: by 10.202.214.205 with HTTP; Thu, 29 Jan 2015 15:01:34 -0800 (PST) In-Reply-To: References: Date: Fri, 30 Jan 2015 01:01:34 +0200 Message-ID: To: Yasuo Ohgaki Cc: Andrea Faulds , "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Use of {} with member. From: narf@devilix.net (Andrey Andreev) Hi, On Fri, Jan 30, 2015 at 12:49 AM, Yasuo Ohgaki wrote: > Hi Andrea, > > On Fri, Jan 30, 2015 at 7:17 AM, Andrea Faulds wrote: >> >> I would expect that anything within ${} works the same as it does outside >> it. Having $obj->${array[$key]} do something different to $key = >> array[$key], $obj->${$key} would make no sense to me. > > > Good point! I forgot about variable variable. > PHP works as follows now. > > http://3v4l.org/dpbES > > Andrey, the reason why you are surprised is probably because of this > // echo "${obj->var}"; // Syntax error > Not entirely ... I just have it as a rule of thumb that if it's not valid code with nothing around it, I shouldn't expect it to be valid inside curly braces (excluding the semicolon of course). Pretty much what Andrea said ... is a syntax error, so I don't expect ${array['foo']} to be valid either. In fact, I just checked and it's not: http://3v4l.org/B6kdv echo "${array['foo']}"; probably works only because of how variables are parsed inside double quotes. Cheers, Andrey.