This article introduces the usage of heredoc in PHP, which can output long paragraphs of document content. Some friends may refer to it.
Heredoc technology, in most programming examples, generally only a Perl-style string output technology is introduced. Nowadays, many PHP programs cleverly use heredoc technology to partially realize the quasi-separation of interface and code. Among them, phpwind template is a typical application example. For example: <?php $name = '脚本 学堂'; print <<<EOT <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>bbs.it-home.org</title> </head> <body> <!--12321--> Hello,$name! </body> </html> EOT; ?> Copy after login Instructions:
1. Start with the << 3. Heredoc is commonly used when outputting documents containing a large number of HTML syntax.
For example: the function outputhtml() should output the HTML homepage. can be written in two ways. Obviously the second way of writing is simpler and easier to read. |