CHALLENGE: how to interpolate constants and variables in PHP double-quoted strings and "heredocs". | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

CHALLENGE: how to interpolate constants and variables in PHP double-quoted strings and "heredocs".

You can easily interpolate variables in PHP double-quoted strings and "heredocs", but constants, functions and mathematical operations are normally not Algerier allowed. The only usual way is string concatenation, but the result can be messy (and it's not possible with 'heredocs'). I've come with a solution below. Does anyone has a better one?

17th Feb 2018, 9:08 PM
Bruno Della Motta
Bruno Della Motta - avatar
1 Answer
17th Feb 2018, 9:09 PM
Bruno Della Motta
Bruno Della Motta - avatar