On 08.10.2021 at 12:57, Kirill Nesmeyanov wrote:
> Yes you are right. The same thing happens if you put a function there.
> ```
> function hi(): string
> {
> return ‘World’;
> }
>
> echo <<<MSG
> Hello ${hi()}
> MSG;
> // Warning: Undefined variable $World!
> ```
>
> For some reason, I did not take this case into account.
>
> Although it seems to me such semantics are old and require removal from the
> language, I admit that there is code that uses it and changing the behavior
> will break a lot. Ideally, I would like to see a similar behavior:
> ```
> echo "Hello ${ $var }"; // Hello World
> echo "Hello ${ 'Wo' . 'rld' }"; // same
> echo "Foo ${ some_foo(42) }";
> echo "Foo ${ 23 + 42 }";
> echo "Some ${ ClassName::method() >> 2 ?? $any }";
> // etc
> ```
See also
<https://wiki.php.net/rfc/deprecate_dollar_brace_string_interpolation>.
--
Christoph M. Becker
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php