search
  • Sign In
  • Sign Up
Password reset successful

Follow the proiects vou are interested in andi aet the latestnews about them taster

PHP EOF(heredoc)

Collection 1351
Read 450446
update time 2016-09-11

##Usage overview:

  • 1. It must be followed by a semicolon, otherwise the compilation will not pass.

  • 2.EOF can be replaced by any other character, as long as the end identifier is consistent with the start identifier.

  • 3. The end mark must occupy a line by itself (that is, it must start from the beginning of the line, and cannot be connected with any blanks or characters before and after).

  • 4. The start mark can be without quotation marks or with single and double quotation marks. Without quotation marks, the effect is the same as with double quotation marks. Embedded variables and escape symbols are interpreted. With single quotation marks, the effect is the same. Embedded variables and escape symbols are not interpreted.

  • 5. When the content requires embedded quotation marks (single quotation marks or double quotation marks), there is no need to add escape characters. The single and double quotation marks will be escaped by itself. This is equivalent to q and Usage of qq.


  • ##Example
<?php
echo <<<EOF
        <h1>我的第一个标题</h1>
        <p>我的第一个段落。</p>
EOF;
// 结束需要独立一行且前后不能空格
?>

Note:

1. Start with <<<EOF start tag and end with EOF end tag , the closing tag must be written at the beginning, there must be no indentation or spaces, and there must be a semicolon at the end of the closing tag.

2. The start tag and the end tag are the same, such as commonly used uppercase EOT, EOD, EOF, but not limited to those (can also use: JSON, HTML, etc.), as long as the start tag and end tag are ensured The markup does not need to appear in the text.

3. Variables located between the start tag and the end tag can be parsed normally, but functions cannot. In the heredoc, variables do not need to be spliced ​​with connectors . or , as follows:

<?php
$name="runoob";
$a= <<<EOF
        "abc"$name
        "123"
EOF;
// 结束需要独立一行且前后不能空格
echo $a;
?>


Hot AI Tools
Undress AI Tool
Undress AI Tool

Undress images for free

AI Clothes Remover
AI Clothes Remover

Online AI tool for removing clothes from photos.

Undresser.AI Undress
Undresser.AI Undress

AI-powered app for creating realistic nude photos

ArtGPT
ArtGPT

AI image generator for creative art from text prompts.

Stock Market GPT
Stock Market GPT

AI powered investment research for smarter decisions

Popular tool
Notepad++7.3.1
Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version
SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1
Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6
Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version
SublimeText3 Mac version

God-level code editing software (SublimeText3)