I am wondering, What is the proper way for inserting PHP variables into a string?
This way:
echo \"Welcome \".$name.\"!\"
I prefer this all the time and found it much easier.
echo "Welcome {$name}!"
Go with the first and use single quotes!
The only situations when you should use double quotes, is when you need \r
, \n
, \t
!
The overhead is just not worth it to use it in any other case.
You should also check PHP variable concatenation, phpbench.com for some benchmarks on different methods of doing things.