Phpheredoc and phpwind template technology usage summary

Source: Internet
Author: User
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 the quasi-separation of interfaces and codes. phpwind is a typical example. In the PHP document, we only mentioned that echo can use the following command to output multi-line strings (and the variables are automatically replaced ):

PHP code

The code is as follows:


Echo < This uses the "here document" syntax to output
Multiple lines with $ variable interpolation. Note
That the here document terminator must appear on
Line with just a semicolon. no extra whitespace!
END;



The above END Terminator can be defined as "EOT" in Phpwind. However, it must be noted that this END can only be valid at the beginning of a row, which is actually a limitation of Heredoc technology (because heredoc can customize the Terminator, so this problem is introduced), which will be mentioned below.

Phpwind template files are generally stored in the templatewind Directory. in the BBS Directory, use the require statement to include the template file. In fact, this Template file is executed as part of the corresponding php file, so you do not need to parse the Template as PHPLib Template, and then execute the process.

To enable the heredoc content to be correctly recognized by an editor like DreamWeaver to implement the "what you see is what you get" webpage design, you need to add comments to heredoc. The example file is as follows:

PHP code

The code is as follows:







Untitled Document





Hello, $ name!








Such a template file is actually a standard PHP file that can be executed. However, the HTML style of such a PHP file can be correctly displayed in DreamWeaver. all PHP code will be seen as HTML comments and will not be output during output. For example, the above file is displayed in DreamWeaver as follows:

PHP code

The code is as follows:


Hello, $ name!



In this way, we can use the DW visual interface to modify and beautify the page. Although code and HTML are not completely separated, it provides at least an auxiliary design method.

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.