I was watching a PHP tutorial and noticed that the teacher was adding varibles to his echo statements in a different way to me. This got me thinking, which way should I be using? Is one more correct than the other?
Here's what the teacher was doing
echo "Example " . $example;
Here's what I do
echo "Example $example";
My method works, but I don't want to get into any bad habits. Could someone please tell me which way I should be using (preferably with some evidence)?
{}-echo "Example {$example}";echo "Example ", $example;also works. notecommaas the separator rather than afullstopwhich is the concatenation operator. It is useful when dealing with strings which use the different types of qoute characters in a string.