Re: [RFC][Under discussion ] Deprecate ${} string interpolation
| From: | Rowan Tommins | Date: | Sat, 12 Mar 2022 11:11:16 +0000 |
| Subject: | Re: [RFC][Under discussion ] Deprecate ${} string interpolation | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-117309@lists.php.net to get a copy of this message | ||
On 12 March 2022 02:11:38 GMT, BohwaZ <php@bohwaz.net> wrote:
>This RFC is confusing two different things:
>
>1. variables inside strings (options 1, 2, 3)
>2. dynamic variables names (option 4)
>
>The 4th one is very useful.
>
>$v = ${'param_' . $name};
>
>There is no other practical way to do that, so removing that feature
>would mean breaking something useful with no replacement.
I don't see anything in the RFC that would break that example. The RFC is *only* about how
variables are interpolated *inside quoted strings*.
As pointed out in the RFC, this syntax looks the same but works subtly differently inside a string,
such that (string)${foo} !== "${foo}" (one dereferences a constant, the other
doesn't).
Full handling of variable-variables is available in the full interpolation syntax,
"{$...}", so "{${foo}}" *does* give the same result as (string)${foo}, and
"{${'param_' . $name}}" gives the same result as (string)${'param_' .
$name}. https://3v4l.org/aRMaq
@Ilija It might be worth adding the above example to the RFC , to show that "Option 2" can
actually do everything that the other options do and more.
Regards,
--
Rowan Tommins
[IMSoP]