On 12 March 2022 02:11:38 GMT, BohwaZ <[email protected]> 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]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php