DEV Community

Discussion on: Favorite String Literals

Collapse
 
leob profile image
leob

PHP also has them :)

Collapse
 
pyrsmk profile image
Aurélien Delogu

Not really. It just has "anything that begins with a $ sign" interpolation. Which is quite annoying IMO 😅

Collapse
 
fjones profile image
FJones

Fair, but PHP does still (unless I missed something) distinguish between interpolated (" and <<<END") strings and non-interpolated ones.

Thread Thread
 
pyrsmk profile image
Aurélien Delogu

Indeed. Single quoted strings cannot be interpolated.

Thread Thread
 
fjones profile image
FJones

Neither can NOWDOC (<<<'END'), which is quite important at times. HEREDOC (<<<END) does get interpolated.

There's few reasons to choose interpolation in PHP, but the ones I've found over the years tend to actually be HEREDOC rather than regular string literals (code generation with HEREDOC is lovely!).

Thread Thread
 
pyrsmk profile image
Aurélien Delogu

I admit that I rarely used them.