PHP delimiter EOF Explanation

Source: Internet
Author: User
Tags closing tag opening and closing tags

This article introduces the content is about the PHP delimiter EOF explanation, has a certain reference value, now share to everyone, the need for friends can refer to

Heredoc technology. HTML and JavaScript scripts that can be used to output large segments

The function of the 1.PHP delimiter is to follow the original, including the newline format, and output something inside it;
2. Any special characters in the PHP delimiter do not need to be escaped;
The PHP variable in the 3.PHP delimiter is replaced with its value as normal.
As follows:

<?php    $name = ' Shallow Water tour ';    There is no space behind <<<eot    print <<<eot            
<?php$out = <<<eof    <a href= "Javascript:edit (' ASD ', ' aaa ')" > Edit </a> |    <font color= "#ccc" > Delete </font>    <a href= "Javascript:confirmurl ('? m=admin&posid=12 ')" > Delete </a> |    <font color= "Red" > Enable </font></a> |      <a href= "Javascript:preview (' 3 ', ' ds ')" ><font color= "Green" > Demo </font></a>eof;echo $out;? >

Attention:

1. Start with the <<<end start tag, end With end tag, * * The end tag must be written in the header * *, cannot have indents and spaces, and a semicolon at the end of the closing tag. 2. The start tag is the same as the start tag, such as EOT, EOD, and EOF, but not limited to those, as long as the start tag and end tag are not present in the body. 3. Variables located between the opening and closing tags can be parsed normally, but the function is not. In Heredoc, a variable does not need a connector. Or, to splice, as follows: $v =2; $a = <<<eof "abc" $v "123" Eof;echo $a; The result is output together with double quotes: "ABC" 2 "123"
4.heredoc is often used when the output contains a large number of HTML syntax D documents. For example: function outputhtml () to output the HTML home page. There are two ways to do this. Obviously the second is simpler and easier to read. The first function outputhtml () {    echo "

Heredoc technology. HTML and JavaScript scripts that can be used to output large segments

The function of the 1.PHP delimiter is to follow the original, including the newline format, and output something inside it;
2. Any special characters in the PHP delimiter do not need to be escaped;
The PHP variable in the 3.PHP delimiter is replaced with its value as normal.
As follows:

<?php    $name = ' Shallow Water tour ';    There is no space behind <<<eot    print <<<eot            
<?php$out = <<<eof    <a href= "Javascript:edit (' ASD ', ' aaa ')" > Edit </a> |    <font color= "#ccc" > Delete </font>    <a href= "Javascript:confirmurl ('? m=admin&posid=12 ')" > Delete </a> |    <font color= "Red" > Enable </font></a> |      <a href= "Javascript:preview (' 3 ', ' ds ')" ><font color= "Green" > Demo </font></a>eof;echo $out;? >

Attention:

1. Start with the <<<end start tag, end With end tag, * * The end tag must be written in the header * *, cannot have indents and spaces, and a semicolon at the end of the closing tag. 2. The start tag is the same as the start tag, such as EOT, EOD, and EOF, but not limited to those, as long as the start tag and end tag are not present in the body. 3. Variables located between the opening and closing tags can be parsed normally, but the function is not. In Heredoc, a variable does not need a connector. Or, to splice, as follows: $v =2; $a = <<<eof "abc" $v "123" Eof;echo $a; The result is output together with double quotes: "ABC" 2 "123"
4.heredoc is often used when the output contains a large number of HTML syntax D documents. For example: function outputhtml () to output the HTML home page. There are two ways to do this. Obviously the second is simpler and easier to read. The first function outputhtml () {    echo "

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.