Reputation:
I'm writing 2 variables in a double quoted string: $j
and $r
, but I want to write a literal string immediately after $j
. The trouble is that if I write "$jx$r"
, then PHP treats the string as $jx
and $r
.
How can I separate the leading variable ($j
) from the literal string (x
)?
Upvotes: 1
Views: 1192
Reputation: 38981
You need to reformat your string a litte:
Tis might be easier to read:
echo $j."x".$r
But if you want it in one string:
echo "{$j}x$r";
See the manual page for double quoted strings
, there is also an explaination how the curly braces work.
Upvotes: 9