Re: [RFC][Under discussion] Deprecate ${} string interpolation
| From: | Lynn | Date: | Sat, 12 Mar 2022 10:44:05 +0000 |
| Subject: | Re: [RFC][Under discussion] Deprecate ${} string interpolation | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-117307@lists.php.net to get a copy of this message | ||
On Sat, Mar 12, 2022 at 3:11 AM 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};
>
Please don't ever ever ever write code like that!
> There is no other practical way to do that, so removing that feature
> would mean breaking something useful with no replacement.
>
While it's still a problematic way of writing code, you can use arrays
instead:
`$v = $something['param_' . $name] ?? null;
This at least keeps all the issues to the scope of
$something.
> Also why break something that works and is used?
>
Variable variables should be removed from PHP asap. It's 2022 and I still
encounter bugs due to this "working" in legacy applications.