Home  >  Article  >  Backend Development  >  Summary of how to use the template technology of php heredoc and phpwind_PHP tutorial

Summary of how to use the template technology of php heredoc and phpwind_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:53:17777browse

In the PHP documentation, it is only mentioned that echo can output multi-line strings using the following command (and the variables in it are automatically replaced):

PHP code

Copy 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 a
line with just a semicolon. no extra whitespace!
END;


The above END terminator can be your own As a rule, in Phpwind, "EOT" is used to end. However, it should be noted that this END must be at the beginning of a line to be valid. This is actually a limitation of Heredoc technology (because heredoc can customize the end character, this problem is introduced), which will be mentioned below.

The template file of phpwind is generally stored under the templatewind directory. In the BBS directory, use the require statement to include this template file. In fact, this template file is executed as part of the corresponding PHP file, so there is no need to parse the template and then execute it like PHPLib Template.

In order for the content of the heredoc to be correctly recognized by editors such as DreamWeaver to achieve "what you see is what you get" web design, comments need to be added to the heredoc. The sample file is as follows:

PHP code
Copy code The code is as follows:



Hello,$name!

EOT                                                                                 !-- 
EOT; 
?> 
--> 


A template file like this is actually a standard, executable PHP file. However, the HTML style of such a PHP file can be displayed correctly in DreamWeaver. All PHP codes will be regarded as HTML comments and will not be output when outputting. For example, the above file is displayed as:

PHP code



Copy code

The code is as follows:


Hello,$name!


In this way, when designing the page, we can use the visual interface of DW to carry out some interface modifications, beautification and other work. Although it does not achieve complete separation of code and HTML, it at least provides an auxiliary design method.


http://www.bkjia.com/PHPjc/318746.htmlwww.bkjia.com
true

http: //www.bkjia.com/PHPjc/318746.html
TechArticle

In the PHP documentation, it is only mentioned that echo can use the following command to output a multi-line string (and the variables in it automatically replaced): PHP code copy code code is as follows: echoEND Thisu...

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn