Difference between single and double quotation marks in php and php. The difference between single and double quotation marks in php. The difference between php double quotation marks is in PHP. The definition of a string can be either single or double quotation marks. However, you must use the same single or php single double quotation marks, and php double quotation marks.
In PHP, strings can be defined using single quotes.' '. You can also use double quotation marks." ".
However, the same single or double quotation marks must be used to define strings, for example:'Hello World"And"Hello World'Is an invalid string definition.
What is the difference between single quotes and double quotes?
PHP allows us to directly include double quotation marksString variable.
The content in a single quotation mark string is generally considered a common character, so the content in a single quotation mark is not escaped more efficiently.
For example:
$ Str = 'hello'; echo "str is $ str"; // running result: str is helloecho 'Str is $ str '; // running result: str is $ str
In php, variables ($ var) and special characters (\ r \ n) in double quotes are escaped, and the content in single quotes is not escaped (so it is more efficient ).
In use,
I used to like writing $ SQL = "SELECT * FROM table WHERE id = $ id" in the SQL string, so that the $ id in it can be escaped, and it won't work in single quotes.
There is no difference between single quotes and double quotes in JavaScript, as long as they are used in pairs.
Most of the single quotes I use in JavaScript are Because Javascript has a lot of dealings with HTML. When outputting HTML fragments, you do not need to escape the attribute quotation marks in HTML.
In short, it depends on the actual situation and how to use it conveniently.
Http://www.bkjia.com/PHPjc/962878.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/962878.htmlTechArticlephp single double quotes difference, php double quotes difference in PHP, the definition of the string can use the English single quotes '', you can also use the English double quotes "". However, you must use the same single or...