...EOF;" syntax."/> ...EOF;" syntax.">
Home > Article > Backend Development > Usage of php eof
php eof usage: First create a PHP sample file; then define a string through the "echo b0d5af8116ab785c6b395461bd16df96...473f0a7621bec819994bb5020d29372aEOF;" syntax Can.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
PHP EOF usage instructions
Let’s introduce how to use EOF, as follows:
PHP EOF (heredoc) is a command line shell (such as sh, csh, ksh, bash, PowerShell and zsh) and program How to define a string in languages like Perl, PHP, Python, and Ruby.
Usage overview is as follows:
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 and the start identifier are consistent.
3. The end mark must occupy a line by itself at the top of the line (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 or double quotation marks. Without quotation marks, the effect is the same as with double quotation marks. Embedded variables and escape symbols will be interpreted. With single quotation marks, embedded variables will not be interpreted. and escape symbols.
5. When the content requires embedded quotes (single quotes or double quotes), there is no need to add escape characters. Single and double quotes are escaped by itself. This is equivalent to the usage of q and qq.
The following is a simple example:
<?php echo <<<EOF <h1>我的第一个标题</h1> <p>我的第一个段落。</p> EOF; // 结束需要独立一行且前后不能空格 ?>
Note the following points:
1. Start with << 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 heredoc, variables do not need to be spliced with connectors . or , as follows: [Recommended learning: PHP video tutorial] The above is the detailed content of Usage of php eof. For more information, please follow other related articles on the PHP Chinese website!<?php
$name="runoob";
$a= <<<EOF
"abc"$name
"123"
EOF;
// 结束需要独立一行且前后不能空格
echo $a;
?>