In PHP, the definition of a string can use English single quotes '' or English double quotes ''.
But the same type of single or double quotes must be used to define the string, such as: 'Hello World' and 'Hello World' are illegal string definitions.
What is the difference between single quotes and double quotes?
PHP allows us to include string variables directly in double-quoted strings.
The content in single quote strings is always considered as ordinary characters, so the content in single quotes will not be escaped, which is more efficient.
For example:
$str='hello'; echo "str is $str"; //运行结果: str is hello echo 'str is $str'; //运行结果: str is $str
In php, variables ($var) and special characters (rn and the like) in double quotes will be escaped, but the content in single quotes will not be escaped (so it is more efficient).
In terms of use, I used to like to write $sql = "SELECT * FROM table WHERE id = $id" in the sql string, so that the $id inside can be escaped, but single quotes cannot.
There is no difference between single quotes and double quotes in JavaScript, as long as they are used in pairs.
I mostly use single quotes in JavaScript because Javascript deals with HTML a lot. When outputting HTML fragments, there is no need to escape the quotes of attributes in HTML.
In short, it depends on the actual situation, how convenient and how to use it.