Summary of php heredoc application

Source: Internet
Author: User
Heredoc of php uses the summary Heredoc technology, which is not detailed in the formal PHP documents and technical books. it only mentions that it is a Perl-style string output technology. However, some forum programs and some article systems use heredoc to partially implement quasi-separation of interfaces and codes, for example: & lt ;? Php $ name = 'Summary of heredoc usage for Shanyu php
Heredoc technology is generally not detailed in regular PHP documents and technical books. it only mentions that it is a Perl-style string output technology. However, some forum programs and some article systems use heredoc to partially implement quasi-separation of interfaces and codes.

For example:

   
  Untitled Document   
 Hello, $ name! EOT;?>


I. With < The ending mark must be at the top of the mark, and there must be no indentation or space and a semicolon at the end of the ending mark. The start tag is the same as the start tag,For example, EOT, EOD, and EOF are commonly used in uppercase, but they are not limited to only a few. you only need to ensure that the start mark and end Mark do not appear in the body.


II. Located between the start mark and end mark Variables can be parsed normally., The function is not allowed.. In heredoc, variables do not need to be concatenated with connectors. or.

For example:
$ V = 2; $ a = <
  
   

3.. Heredoc is often used to output a large number of HTML syntax d documents. For example, the outputhtml () function outputs the HTML homepage. There can be two writing methods. Obviously, the second method is relatively simple and easy to read.

Function outputhtml () {echo""; Echo"Home Page"; Echo"Homepage content"; Echo";} Function outputhtml () {echo <
       
     Home Page   Homepage content   EOT;} outputhtml ();
    

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.