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?

A delimiter is a $str=<<

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:

<?php//php constants, can be modified to delete $name= "Zhang San"; Echo $name; echo "<br/>"; $name = "John Doe"; Echo $name; echo "<br/>";//notice: Undefined Variable:name in ... Unset ($name); echo $name; echo "<br/>";//after constants are defined, cannot be modified and deleted//constant naming suggestions: (1) uppercase; (2) Multiple letters with an underscore to connect define ("age"; ;//If the constant is the following-_-, then the direct echo Word is a syntax error, which needs to be replaced by another way of accessing the constant 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?>



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

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.