There are many possibilities for curly braces (for example, deleting them), and everything becomes even more complicated when working with objects or arrays.
I prefer interpolation for concatenation, and I prefer to skip braces when not needed. Sometimes they are.
You cannot use object operators with the syntax ${} . You must use {$...} when calling methods or chain operators (if you have only one statement, for example, to get a member, curly braces can be omitted).
The syntax ${} can be used for variable variables:
$y = 'x'; $x = 'hello'; echo "${$y}"; //hello
The $$ syntax does not interpolate in a string, making ${} necessary for interpolation. You can also use strings ( ${'y'} ) and even concatenate in the ${} block. However, variable variables can probably be considered bad.
For arrays, either ${foo['bar']} vs. will work {$foo['bar']} . I prefer just $foo[bar] (only for interpolation - outside the line bar will be considered as a constant in this context).
source share