What is the difference between single quotes and double quotes of strings in PHP? What is the difference between delimiters and double quotation marks?

Source: Internet
Author: User
What is the difference between single quotes and double quotes of strings in PHP? What is the difference between delimiters and double quotation marks? (1) What is the difference between single quotes and double quotes?

1. you can use different escape ranges. single quotes can only escape single quotes \ '. double quotes cannot be escaped except single quotes, and other \ "\ n \ r \ t can.

2. php variables can be parsed in double quotation marks. That is, "My name is $ name ".

However, when a variable is used in a string, we instruct $ to indicate the start of the variable, but do not specify the end position of the variable. Therefore, if it is not placed at the end, an error will occur.

Solution:

1. put it at the end. If there is nothing behind it, it is correct.

2. add a space after the variable. When a space is encountered, it ends by default.

3. use braces {}.

4. use the Connector "." or "," to connect characters and variables.


(2) What are the differences between delimiters and double quotation marks?

The identifier, that is, $ str = <

1. the delimiters must be paired.

2. the right delimiters must be in the top space and cannot be indented.

3. there cannot be anything behind the separator start or end.

Difference between delimiters and double quotation marks

1. the delimiter looks easy to read.

2. the format of the output result is retained.


(3) the following statements about variables and constants:

 "; $ Name =" Li Si "; echo $ name; echo"
"; // Notice: Undefined variable: name in... unset ($ name); echo $ name; echo"
"; // After a constant is defined, it cannot be modified or deleted. // recommended for constant naming: (1) uppercase; (2) connecting define (" AGE ", 29); echo AGE; // a syntax error occurs if the constant is, echo constant ("AGE"); // Notice: Constant AGE already defined in... define ("AGE", 30); // Parse error: syntax error, unexpected ')', expecting: (t_paamayim_nekudow.im) in... unset (AGE); // after php is executed, all variables and constants will be released, which will be recycled by the system?>

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.