这个PHP代码代表什么:'<<< INPUT INPUT'?

sas*_*sha -1 php string

我在Zend的页面上找到了这段代码......

<?php
$input = <<<INPUT
some text
INPUT;
?>
Run Code Online (Sandbox Code Playgroud)

好像是......

<?php
$input = 'some text';
?>
Run Code Online (Sandbox Code Playgroud)

我以前从未见过它,也找不到任何关于它的东西.有人可以给我一个关键字吗?

(参见:framework.zend.com/manual/current/en/modules/zend.escaper.escaping-javascript.html)

TY

Riz*_*123 6

这是简单的heredoc语法:http://php.net/manual/en/language.types.string.php

手册中的引用:

字符串文字可以用四种不同的方式指定:

  • 单引号
  • 双引号
  • heredoc语法
  • nowdoc语法(自PHP 5.3.0起)

heredoc就像你拥有它一样:

$input = <<<INPUT
    some text
INPUT;
Run Code Online (Sandbox Code Playgroud)

和nowdoc非常相似:

$input = <<<'INPUT'
          //^     ^ See here the difference
    some text
INPUT;
Run Code Online (Sandbox Code Playgroud)