Home >Backend Development >PHP Tutorial >PHP about the usage of <<<
YUN77.NET Hong Kong server free trial welcome to visit~~~ Heredoc technology is generally not described in detail in formal PHP documents and technical books. It is only mentioned that it is a Perl-style string output technology. However, some current forum programs and some article systems cleverly use heredoc technology to partially realize the quasi-separation of interface and code. The phpwind template is a typical example. As follows: $name = 'Shallow water swimming'; print << Hello, $name! EOT; ?> 1. Start with the << $v=2; $a= << "123" EOF; echo $a; //The result is output together with double quotes: "abc"2 "123" 3. Heredoc is often used when outputting documents containing a large number of HTML syntax documents. For example: the function outputhtml() should output the HTML homepage. There are two ways to write it. Obviously the second way of writing is simpler and easier to read. function outputhtml(){ echo ""; echo " echo "Homepage content"; echo "; } function outputhtml() { echo << Homepage content EOT; } outputhtml(); |