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.