Notes for php learning _ 3_php syntax and hereDoc and nowDoc

Source: Internet
Author: User
: This article mainly introduces notes about the php learning notes _ 3_php syntax and hereDoc and nowDoc. if you are interested in PHP tutorials, refer to them. Notes for PHP:

In an html statement file, whether it is an html file or a php file, you can add a php statement anywhere, but it must have a start and end mark, that is'
  'The php Terminator does not need to be added when the php file is pure, for example, '?> 'Variables can be directly used without being declared. single quotation marks and double quotation marks: single quotation marks do not parse variables. double quotation marks parse variables single quotation marks and double quotation marks: single quotation marks only parse '\', the two escape characters '\' are output as they are without parsing the escape characters in double quotation marks. In html, '\ n',' \ r', '\ tab' are converted into a space on the page. Brackets can be used to distinguish variables from other characters, for example, '$ {variable name}' and '{$ variable name}', and no space exists between the brackets and variables, otherwise, curly braces will be output.

Garbled problem:
The page is a Chinese garbled text. when a file is saved with any encoding, it needs to be opened with the corresponding encoding. if the encoding used for printing does not match the saved encoding, garbled text will appear.
When the page is garbled, you can add the corresponding method encoding in the header of the page:

For example, the head is added to the label:
  If it is a PHP file, you can enter the following statement header ('content-type: text/html; charset = utf-8 ');

In php, in addition to using single quotes and double quotes as strings, you can also use HereDoc and NowDoc
HereDoc starts with three minor signs, which is equivalent to double quotation marks, that is, variables that can be parsed. the format is as follows:

<
  <名称 html内容 名称;例:
   
This is an example of hereDoc.
   

HereDoc is suitable for inputting html with long text in php files

TABLE;?>


NowDoc is similar to HereDocs, but the name must be enclosed in double quotation marks. it can be used above php5.3, which is equivalent to single quotation marks, that is, the content output as is, as follows:

<"Name": html content name; example:
  This is an example of nowDoc.

NowDoc is equivalent to double quotation marks

TABLE;?>

Copyright Disclaimer: This article is an original article, and the Reprinted article must indicate the source. the viewpoint of this article only represents the current opinion, which must be insufficient. thank you very much for your attention!

The preceding section describes notes about the php learning notes _ 3_php syntax and hereDoc and nowDoc, including related content, and hopes to help those who are interested in the PHP Tutorial.

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.