PHP delimiter <<<eof Explanation

Source: Internet
Author: User
Tags opening and closing tags

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 ' ;  //  below <<<eot cannot have spaces after  print  <<<eot   Hello , { $nam E }!             Hello ,  $name ! </body> EOT;  //  Note that the Terminator at the end must be pulled over, preceded by a space ? 
<? 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 **, no indents and spaces, and a semicolon at the end of the tag.  2.  The start tag is the same as the start tag, such as the usual uppercase EoT, EOD, EOF, but not limited to the few, as long as the start and end tags 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,   $v  =2  $a  = <<<eof  "abc"  $v " 123 "eof;  echo   $a ; //  result with double quotes output: "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 ";     Echo ";     Echo "<body> Home content </body>";     Echo "

PHP delimiter <<<eof Explanation

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.