Single quotes in PHP double quotes

Source: Internet
Author: User
: This article mainly introduces the single quotation marks in PHP double quotes. if you are interested in the PHP Tutorial, please refer to them. PHP processes strings in different ways, depending on whether the strings are enclosed by single quotes or double quotes.

1. single quotes are considered as original text, while PHP looks for variables when processing double quotes.

2. to reference a single quotation mark in a single quotation mark, or to reference a double quotation mark in a double quotation mark, you must add a transfer character. for example:

'Mother \'s glass' and "his name is \" jack \""

3. if the quotation marks do not conflict with each other, you do not need to escape them. for example, double quotation marks in single quotation marks or single quotation marks in double quotation marks, such

"Mother's glasses" and 'His name is "jack "'

4. single quotes only support escape characters \ 'and \. other escape characters can only be used in double quotation marks.

PS: The above is the existing knowledge, and write this blog post for the following example:

I have never understood that the VALUES in the SQL statement requires single quotation marks, but the INSERT statement does not. now I understand that it is because this SQL statement is written like this:

Insert into email_list (first_name, last_name, email) VALUES ('string1', 'string2', 'string3 ')

That is to say, the value in the brackets of VALUES should be enclosed in quotation marks, while $ firstname in double quotation marks will be translated into its own value, such as string1, rather than single quotation marks, in fact, the single quotes are only part of the string.

The preceding section describes the single quotation marks in PHP double quotes, including some content. it is helpful for anyone interested in PHP tutorials.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.