Php reference string constants

Source: Internet
Author: User
Php reference string constants

  1. $ Name = 'utuo ';
  2. // Single quotation mark string
  3. Echo 'My name is $ name ';
  4. // Single quotation mark string
  5. Echo "my name is $ name ";
  6. Echo "my name is {$ name }";
  7. // Here document string
  8. Echo <end
  9. My name is $ name
  10. My name is {$ name}
  11. End;

The result is (there is no line feed in the output, so it is easy to understand.): my name is $ namemy name is yutuomy name is yutuo

The following describes the single quotes, double quotes, and here documents from unix shell.

1. single quotes string refers to a string enclosed by single quotes. It only supports two escape characters, backslash (\) and single quotation mark ('), which are expressed as (\) and (\') respectively. Note that single quotes strings do not support line breaks (\ n), but single quotes strings can be defined across rows. The following code: echo 'My name is yutuo. I am studing php. '; the result is (the output result contains a line break): my name is yutuo. I am studing php.

2. double quotation mark string refers to the string enclosed by double quotation marks. It only supports multiple escape characters and can be defined across rows. There are braces and brackets in the book, but I did not test them in php5.3.1. The escape character list of its sub-branch is as follows:

\ "Double quotation marks \ n Newline \ r carriage return \ t tab \ backslash \ $ Dollar character \ 000 ~ 777 octal ascii code \ x00 ~ Ff hexadecimal ascii code

3. here documents can easily put multiple lines of text into the program. In addition to different definition methods, the escape characters, cross-line definition, and double quotation marks are exactly the same. The method is defined as <identifier, ending with a single row identifier. Note that < <和标识符之间有一个空格,结尾标识符前不能有空格。< p>

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.