What is the difference between a single quotation mark and a double quote for a string in PHP? Delimiter and double quote difference?

Source: Internet
Author: User
Tags parse error
(1) What is the difference between single and double quotation marks?

1, can be used to escape the range, the single quotation mark can only escape the single quotation mark \ ', double quotation marks except single quotation mark cannot escape, other \ "\n\r\t can.

2, double quotation mark can parse PHP variable, single quotation mark cannot. That is, "my name is $name."

However, using a variable in a string, we instruct $ to indicate that the variable starts, but does not specify the end position of the variable, so an error occurs if it is not at the end.

Solution:

1, put at the end. There is nothing in the back, and nature is right.

2. Add a space after the variable. The default end of a space is encountered.

3. Use curly braces {}.

4. Use the connector "." Or ",", concatenate characters and variables.


(2) What is the difference between a delimiter and a double quote?

The delimiter is $str=<<. < p="">

1, the delimiter must be paired.

2, the right delimiter must be shelf, can not have any indentation.

3, the delimiter starts and Terminator cannot have anything behind.

Delimiter and double quote differences

1. The delimiter appears to be easy to read format.

2, the result of the delimiter output preserves the format.


(3) The following are some statements of variables and constants:

 
  "; $name =" John Doe "; Echo $name; echo"
";//notice:undefined variable:name in ... Unset ($name); echo $name; echo.
";///constants can not be modified and deleted//constants after definition: (1) uppercase; (2) When multiple letters are underlined to connect define (" age ",); Echo age;//If the constant is the following-_-, then the direct echo is a syntax error, The way to change to another access constant is ECHO constant ("age");//notice:constant-already defined in ... Define ("Age",//parse error:syntax error, unexpected ') ', Expecting:: (T_paamayim_nekudotayim) in ... Unset (age); After//php execution, all variables and constants are released and collected 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.