聘我网

新概念招聘3.0

<<<是什么语法?

vote up0vote downstar
$test= <<<EOF

....

EOF;

从未见过,这是干嘛的?

 

1 个答复

vote up0vote downcheck

这是HEREDOC syntax

用于定义多行的字符串。

Heredoc text behaves just like a double-quoted string, without the double quotes. This means that quotes in a heredoc do not need to be escaped, but the escape codes listed above can still be used. Variables are expanded, but the same care must be taken when expressing complex variables inside a heredoc as with strings.

$a = 'World';
$string = <<<MARKER
<p>
  Hello, $a!
</p>
MARKER;
echo $string;

将输出:

<p>
  Hello, World!
</p>
链接

您的回答





不是您要找的问题? 浏览其他含有标签 的问题或者 自己问个.