Im just curious as to what is the difference to these 3 types of strings.
echo "Hello my name is ".$name;
echo "Hello my name is $name";
echo "Hello my name is {$name}";
I know that in the third case its required over the 2nd when your using arrays with keys. For example, i know the following wont work.
echo "Hello my name is $data['name']";
You would need to do…
echo "Hello my name is{$data['name']}";
for it to work.
Does anyone have an explanation as to why this is?
People are giving their opinion, it’s fine, but here are facts :
Basically, it does not matter how you do it, just choose your favorite and stick with it. If you work with a group of people, just use the same convention, for clean code’s sakes.