Possible Duplicate:
Difference between single quote and double quote string in php
In PHP, do both ( " )
and ( ' )
have the same effect? I'm new to PHP and I've been using them interchangeably. Can I?
Possible Duplicate:
Difference between single quote and double quote string in php
In PHP, do both ( " )
and ( ' )
have the same effect? I'm new to PHP and I've been using them interchangeably. Can I?
Yes you can use single quoted or double quoted strings but they have some differences. Take a look at php string type.
You you can use them interchangeably, however following are differences:
Inside double quotes, php is able to parse variables for example
"Hello $name" // result: Hello [whatever stored in $name eg John]
Inside single quotes php is not able to parse variables:
'Hello $name' // result: Hello $name
Since php does not parse variables from single quotes, using single quotes is slightly faster.
More Information:
$name = 'Amar';
echo "Hello, $name"; // outputs Hello, Amar
echo 'Hello, $name'; // outputs Hello, $name
Single quotes ( ' ) are faster by a very small margin since they don't need to scan strings for variables.