我在Zend的页面上找到了这段代码。。。
<?php
$input = <<<INPUT
some text
INPUT;
?>
看起来就像。。。
<?php
$input = 'some text';
?>
我以前从未见过,也找不到任何关于它的信息。有人能给我一个关键词吗?
(参见:framework.zend.com/manual/current/en/modules/zend.escaper.escapejavascript.html)
ty
这是一个简单的heredoc语法:http://php.net/manual/en/language.types.string.php
引用手册:
字符串文字可以用四种不同的方式指定:
- 单引号
- 双引号
- heredoc语法
- nowdoc语法(自PHP 5.3.0起)
heredoc会和你一样:
$input = <<<INPUT
some text
INPUT;
与之非常相似的是nowdoc:
$input = <<<'INPUT'
//^ ^ See here the difference
some text
INPUT;
使用三个小于和一个TAG用于多行字符串。使用开头选择的相同TAG结束多行字符串。在您的情况下,TAG为"INPUT"。