Home  >  Article  >  Backend Development  >  What is the difference between single quotes and double quotes in php?

What is the difference between single quotes and double quotes in php?

王林
王林forward
2019-09-05 17:37:526293browse

What is the difference between single quotes and double quotes in php?

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!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete