Heredoc technology, usually not detailed in regular PHP documentation and technical books, just mentions that this is a Perl-style string output technique. But now some of the forum procedures, and some of the article system, are clever use of heredoc technology, to partially realize the interface and code of the quasi-separation, phpwind template is a typical example.
As follows:
$name = Shallow Water tour;
Print <<<>< p=""><>
Untitled Document
Hello,$name!
EOT;
?>
1. Start with the << <> < span=""><> start tag, End With end tag, end tag must be head written, cannot have indentation and space, And there is a semicolon at the end of the closing tag . The start tag is the same as the start tag, such as the usual uppercase EoT, EOD, EOF, but not limited to those, as long as the start tag and end tag are not present in the body .
2. 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 = <<<>
"ABC"$v
"123"
EOF;
echo $a; The result is output together with double quotes: "ABC" 2 "123"
3.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.
function outputhtml () {
echo "";
echo "Home";
echo "Homepage content";
echo ";
}
function outputhtml ()
{
Echo <<<>
Home
Home Page Content
EOT;
}
Outputhtml ();
http://www.bkjia.com/PHPjc/486030.html www.bkjia.com true http://www.bkjia.com/PHPjc/486030.html techarticle Heredoc technology, usually not detailed in regular PHP documentation and technical books, just mentions that this is a Perl-style string output technique. But now some of the forum programs ...