Brackets in PHP double-quoted strings

Viewed 3094

this is more of a better-practice type of question.

I'd like to know if using brackets in double-quoted strings for variables is good practice.

For example:

<?php
$Variable = 'a variable';
$SingleQuotedString = 'Single quoted string with ' . $Variable;
// Single quoted string with a variable

$DoubleQuotedString = "Double quoted string with $Variable";
// Double quoted string with a variable

$DoubleQuotedStringWithBrackets = "Double quoted string with {$Variable} in brackets.";
// Double quoted string with a variable in brackets.
?>

It doesn't change the output or the code from simple tests, and obviously works. I'm just confused because not many people do this, and I don't see recommendations or people disagreeing with it, and I've been using them just fine.

Thanks for any feedback!

5 Answers
Related