In php, the definition of a string can use either single quotes or double quotes.
Generally, the two are common, but double quotes will parse variables, but single quotes will not.
php allows us to include string variables directly in double quotes.
The content in single quotes will be considered as ordinary characters, so the content in single quotes will not be parsed, and the efficiency is higher.
For example:
$str='hello'; echo "str is $str"; //运行结果: str is hello echo 'str is $str'; //运行结果: str is $str
In PHP, variables and special characters in double quotes will be escaped, but in single quotes they will be treated as ordinary characters and will not be escaped, so , single quotes are more efficient than double quotes.
For more details, please visit the PHP Chinese website: PHP Video Tutorial
The above is the detailed content of What is the difference between single quotes and double quotes in php?. For more information, please follow other related articles on the PHP Chinese website!