Should I use curly brackets or concatenate variables within strings?

Posted by mririgo on Stack Overflow See other posts from Stack Overflow or by mririgo
Published on 2011-01-13T03:07:38Z Indexed on 2011/01/13 3:54 UTC
Read the original article Hit count: 247

Filed under:
|
|

Straight forward question: Is there an advantage or disadvantage to concatenating variables within strings or using curly braces instead?

Concatenated:

$greeting = "Welcome, ".$name."!";

Curly braces:

$greeting = "Welcome, {$name}!";

Personally, I've always concatenated my strings because I use UEStudio and it highlights PHP variables a different color when concatenated. However, when the variable is not broken out, it does not. It just makes it easier for my eyes to find PHP variables in long strings, etc.

EDIT: People are confusing this about being about SQL. This is not what this question is about. I've updated my examples to avoid confusion.

© Stack Overflow or respective owner

Related posts about php

Related posts about concatenation