Reputation: 951
Have I missed something in my years of php or is there no way to do this:
$var = "testString";
echo "$varAndRestOfStringConctd";
// testStringAndRestOfStringConctd
Is there any other way of writing that besides:
echo $var.'AndRestOfStringConctd';
Upvotes: 0
Views: 46
Reputation: 164733
RTM ~ http://php.net/manual/language.types.string.php#language.types.string.parsing.complex
echo "{$var}AndRestOfStringConctd";
An alternative is the often forgotten printf
/ sprintf
functionality
printf('%sAndRestOfStringConctd', $var);
Upvotes: 1
Reputation: 12017
You can put the variable in curly brackets/braces:
$var = "testString";
echo "{$var}AndRestOfStringConctd";
That tells PHP where the variable ends.
Upvotes: 0