Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92332 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 41813 invoked from network); 15 Apr 2016 10:40:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Apr 2016 10:40:10 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.41 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.41 mail-wm0-f41.google.com Received: from [74.125.82.41] ([74.125.82.41:34377] helo=mail-wm0-f41.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EF/02-29891-805C0175 for ; Fri, 15 Apr 2016 06:40:09 -0400 Received: by mail-wm0-f41.google.com with SMTP id l6so8655940wml.1 for ; Fri, 15 Apr 2016 03:40:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=401/Kc3/u78yQtdLenF51j0tBzbQk50aZMnzgdRYw9M=; b=ZsGpxtdnUvKtATdgkdz+HDdl/rvciAzVE4VFUU3Q0Yk8eei9UNTG+RqCWiRSQvCLNo jXOpQ6gVEGdHNdWNk2i99ObLtZqtKOFHxOHYVnaX+52+GbUIwA1T7f6YYecu8ZB8hvR/ 7tZH+CekAM+1UdEzzp2eLdLYTtMZtiRxfiuhfCoiNpRaTI20mIFoZ/UFuzbI5/ecE0GE NrQx1D1MAjJnmzsLc5FlWNzx7ybwPRUQ3/TuKzk7alHAqAWBaLcJnVattaFMzU/bDvon jlVGi/dMQF+VKo6PvPCTB05tgYg6g9TU0ZOuYoWXuMxrVtoJVz6YG+t4wianG/mjT1e6 egXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=401/Kc3/u78yQtdLenF51j0tBzbQk50aZMnzgdRYw9M=; b=SdPu+mRq8Ft2ohTAGUNwm+ubsn7HDTEXGLl6jajSEQJD7phbhiMw1+orc29SoelGxn 0rEiUZgL+5Awyb+5cqLub+XiH5EsxWJrwFhsFXfNTp4ixkcoOvgYKd278ikEFrGmXE0c nmvQZIcJ82JomzIQZHbLfgs1O9Nv1d9JxY1B3QV3HmwEPUJRfl/rF3cK+o3cQHbm7K7C qUm4Ty8A++IAdEgTnrhb5oOo6frzyhPb+LOzYGUmPX7rbllejKjKycfFBjGQ9a5GdT1f e/PTxirjKgXeK5BpvuO7EcBNAM467htXU3QITviOZ9XKy3xughwgf2gkDsamrweZNGIN w2Sg== X-Gm-Message-State: AOPr4FW+8ruNwb+pgLdQValrdncMma9aye8C6tMtu2vnZ1iIiVvBle7vP4WQF8f2qdc66Q== X-Received: by 10.28.109.87 with SMTP id i84mr3804236wmc.3.1460716804644; Fri, 15 Apr 2016 03:40:04 -0700 (PDT) Received: from [192.168.0.119] ([93.188.182.58]) by smtp.googlemail.com with ESMTPSA id x2sm48360886wjr.33.2016.04.15.03.40.03 for (version=TLSv1/SSLv3 cipher=OTHER); Fri, 15 Apr 2016 03:40:03 -0700 (PDT) To: internals@lists.php.net References: <04125064-C4C4-43C1-8EC0-8CD633E3A0F2@simon.geek.nz> Message-ID: <5710C481.8060800@gmail.com> Date: Fri, 15 Apr 2016 11:37:53 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: <04125064-C4C4-43C1-8EC0-8CD633E3A0F2@simon.geek.nz> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] Interpolation using ${} syntax with spaces inside the braces From: rowan.collins@gmail.com (Rowan Collins) Simon Welsh wrote on 15/04/2016 00:52: > When not inside a string, the inside of the ${...} is always treated as an > expression, by both PHP and HHVM (https://3v4l.org/i2kOP), so that looks like the > “correct” handling for inside a string. The in-quotes behaviour makes sense when you consider the use cases it solves, e.g. $foo = 'percent'; echo "${foo}age"; Arguably, the alternative bracketing style is clearer here, and doesn't have the name-expression conflict: $foo = 'percent'; echo "{$foo}age"; So possibly you're right - in an ideal world ${ ... } should evaluate an expression whether inside a string or out, and {$...} can be used inside a string for isolating variables. But given the horrendous BC issues of changing that now, I'm inclined to say that surrounding whitespace should be an error, and force the user to use less ambiguous syntax. It occurs to me that this problem is made worse by the "implicit constant definition" where an undefined constant becomes a string. Removing the definition of the constant from the example, and suppressing notices, gives identical output in all versions: https://3v4l.org/3i2El Leave the notices on, though, and you'll see they're getting to that answer in different ways - PHP is mapping expression -> undefined constant -> string -> variable name. So you could have code that works one way for years, then define a global constant with the same name as the local variable, and suddenly everything would go haywire. I would love to see that implicit definition officially deprecated, but that's for another thread... Regards, -- Rowan Collins [IMSoP]