A summary of the use of template techniques for PHP heredoc and phpwind _php tips

Source: Internet
Author: User
Tags php file dreamweaver
In the PHP documentation, it just mentions that echo can output multiple lines of string (and the variables are automatically replaced) using the following command:

PHP code
Copy Code code as follows:

Echo <<<end
This uses the ' Here Document ' syntax to output
Multiple lines with $variable interpolation. Note
That's here, document Terminator must appear on a
Line with just a semicolon. No extra whitespace!
End;


The end terminator above can be set by itself, in Phpwind, using the "EOT" to finish. Note, however, that this end must be at the beginning of a line to be effective, which is actually a limitation of the Heredoc technology (because Heredoc can customize the terminator, so the problem is introduced), as mentioned below.

Phpwind template files are generally stored under the Templatewind directory, in the BBS directory, using the Require statement contains this template file. In fact, this template file is executed as part of the corresponding PHP file, so you do not need to do the template parsing as Phplib template, and then execute the process.

In order for Heredoc content to be properly identified by an editor such as Dreamweaver for "WYSIWYG" web design, you need to add annotations to the Heredoc, sample files as follows:

PHP code
Copy Code code as follows:

<!--
<?php
Print <<<eot
-->

<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title>untitled document</title>

<body>
<!--
$name = ' Shallow Water tour ';
Print <<<eot
-->

Hello, $name!

<!--
EOT
Print <<<eot
-->

</body>

<!--
EOT;
?>
-->

Such a template file, in fact, is a standard, can be executed PHP file. However, such PHP files, whose HTML style can be displayed correctly in Dreamweaver, all PHP code will be viewed as HTML annotations and will not be output when exported. For example, the above file is shown in Dreamweaver:

PHP code
Copy Code code as follows:

Hello, $name!


In this way, in the design of the page, we can use the visual interface of DW, to make some changes in the interface, landscaping and other work. While complete code and HTML separation is not implemented, at least one complementary design tool is provided.

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.