Reputation: 667
What are the differences in the results of these three strings:
echo "Hello" . "World! <br />";
echo "Hello"; echo "World!" , "<br />";
echo "Hello" , "World!" , "<br />";
Is there any preferred way to concatenate strings or are they all acceptable?
Upvotes: 0
Views: 61
Reputation: 771
The concatenation operator is '.', the comma doesn't concatenate. In the examples you made, only the first one is concatenation.
On the other side, the echo construct, accepts many parameters which are separated by commas.
Upvotes: 1
Reputation: 2711
The preferred way is to use the dot.
Most php programmers don't even know it is possible to use the comma. Having two echo statements is less readable, and slightly less performant.
Upvotes: 1