Is there a difference between using single-quoted and double-quoted strings?
1 Answer
There is a small difference, single-quoted strings don't support interpolation:
{% set string = 'There is a #{car}.' %}
The above example won't work. If you want to use it, you need to wrap your string in double quotes:
{% set string = "There is a #{car}." %}
-
1This is similar to the PHP logic between single and double quotes. Commented Jun 16, 2014 at 22:16
-
Except that you can concatenate string in PHP using single quotes (using "."). Twig still requires double quotes (using "~"). Commented Jun 17, 2014 at 11:22
-
3
-
@ChristianSeelbach Yep. You're right. I misread the Twig docs. Commented Jun 25, 2014 at 15:14