zlacker

[parent] [thread] 5 comments
1. jorams+(OP)[view] [source] 2022-12-08 12:57:16
PHP string interpolation has 3 possible syntaxes: $var, {$var} and ${var}. The last one is now deprecated. I've never seen it used in the wild, and it has some odd limitations. It's discussed in the RFC[1].

[1]: https://wiki.php.net/rfc/deprecate_dollar_brace_string_inter...

replies(3): >>capabl+y >>tyingq+31 >>alt227+E2
2. capabl+y[view] [source] 2022-12-08 13:00:47
>>jorams+(OP)
Interesting that one developer voted no (out of 32 developers in total). Wonder what the reasoning was? Seems like a change with small impact and reduced amount of code to maintain, so not lots of drawbacks.
3. tyingq+31[view] [source] 2022-12-08 13:04:41
>>jorams+(OP)
>I've never seen it used in the wild

I imagine it might crop up for people that also use Perl, since that would be more common there, like:

$foo="abc${var}def";

replies(1): >>trey-j+r2
◧◩
4. trey-j+r2[view] [source] [discussion] 2022-12-08 13:13:59
>>tyingq+31
bash also uses the same syntax, and I've probably used it before for that reason.
5. alt227+E2[view] [source] 2022-12-08 13:14:57
>>jorams+(OP)
Seems strange to remove it when Javascript has introduced it with backtick strings like:

`words ${var} more words`

I thought we would start seeing more usage of this in PHP to make things more consistent.

replies(1): >>graype+p9
◧◩
6. graype+p9[view] [source] [discussion] 2022-12-08 14:04:04
>>alt227+E2
The ${var} syntax is inconsistent with PHP’s own syntax though. Variables are normally referenced with a leading dollar sign, like $var, so if you wanted to make it look like template strings in JS it’d be ${$var} which is over complicated.
[go to top]