3 ms·
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
by jorams 4y ago
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_interpolation https://wiki.php.net/rfc/deprecate_dollar_brace_string_inter...
- capableweb 4y agoInteresting 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.
- tyingq 4y ago>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";
- trey-jones 4y agobash also uses the same syntax, and I've probably used it before for that reason.
- alt227 4y agoSeems 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.
- graypegg 4y agoThe ${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.