PHP: Using a variable inside a double quotes

$imagebaseurl="support/content_editor/uploads/" . $name;

or

$imagebaseurl = "support/content_editor/uploads/{$name}";

Note that if you use double quotes, you can also write the above as:

$imagebaseurl = "support/content_editor/uploads/$name";

It’s good though to get in the habit of using {$...} in double quotes instead of only $..., for times where you need to insert the variable in a string where it’s not obvious to PHP which part is the variable and which part is the string.

If you want the best performance, use string concatenation with single quotes.

Leave a Comment