How to use heredoc in php. 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 of the current forum programs Heredoc technology is not detailed in the formal PHP documentation and technical books, but mentioned 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 template is a typical example.
As follows:
$ Name = shappend games;
Print <
Untitled Document
Hello,$ Name!
EOT;
?>
1.< Start to start, End with End to End, The end mark must be written at the top, with no indentation or spaces, and a semicolon at the end of the end mark.. The start tag is the same as the start tag, for example, EOT, EOD, and EOF in uppercase. The start and end tags do not appear in the body..
2. variables between the start tag and the end tag can be parsed normally,But the function cannot.. In heredoc, variables do not need to be concatenated with connectors. or, as shown below:
$ V = 2;
$ A = < "Abc"$ V
"123"
EOF;
Echo $ a; // The result is output together with double quotation marks: "abc" 2 "123"
3. heredoc is often used to output a large number of HTML syntax d documents. For example, the outputhtml () function outputs the HTML homepage. There can be two writing methods. Obviously, the second method is relatively simple and easy to read.
Function outputhtml (){
Echo"";
Echo"Home Page";
Echo"Homepage content";
Echo";
}
Function outputhtml ()
{
Echo <
Home Page
Homepage content
EOT;
}
Outputhtml ();
Bytes. But now some forum programs...