<<< END在PHP中是什么意思? [英] What does <<<END mean in PHP?

查看:85
本文介绍了<<< END在PHP中是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复项:
参考-这个符号在PHP中是什么意思?
PHP<<< EOB

Possible Duplicates:
Reference - What does this symbol mean in PHP?
PHP <<<EOB

我正在尝试在以下代码中使用END:

I am trying to grok the use of END in the following code:

$javascript_autocomplete_text = <<<END
<script type="text/javascript">
    function split(val) {
        return val.split('\\n');
    }
</script>

推荐答案

此处的语法:

分隔字符串 s的第三种方法是heredoc语法:<<<.在此运算符之后,提供了一个标识符,然后提供了换行符. 字符串本身紧随其后,然后再次使用相同的标识符关闭报价.

A third way to delimit strings is the heredoc syntax: <<<. After this operator, an identifier is provided, then a newline. The string itself follows, and then the same identifier again to close the quotation.

结束标识符必须从该行的第一列开始.此外,标识符必须与PHP中的任何其他标签遵循相同的命名规则:标识符必须仅包含字母数字字符和下划线,并且必须以非数字字符或下划线开头.

The closing identifier must begin in the first column of the line. Also, the identifier must follow the same naming rules as any other label in PHP: it must contain only alphanumeric characters and underscores, and must start with a non-digit character or underscore.

警告非常重要的一点是,带有结束标识符的行除分号(;)之外,不得包含其他任何字符.这尤其意味着标识符不能缩进,并且在分号之前或之后可能没有空格或制表符.同样重要的是要认识到,结束标识符之前的第一个字符必须是本地操作系统定义的换行符.在包括Mac OS X在内的UNIX系统上,这是 \ n .结束定界符也必须后跟换行符.

Warning It is very important to note that the line with the closing identifier must contain no other characters, except a semicolon (;). That means especially that the identifier may not be indented, and there may not be any spaces or tabs before or after the semicolon. It's also important to realize that the first character before the closing identifier must be a newline as defined by the local operating system. This is \n on UNIX systems, including Mac OS X. The closing delimiter must also be followed by a newline.

如果此规则被破坏并且结束标识符不是干净的",它将不被视为结束标识符,PHP将继续寻找一个.如果在当前文件末尾之前找不到合适的结束标识符,则会在最后一行产生解析错误.

If this rule is broken and the closing identifier is not "clean", it will not be considered a closing identifier, and PHP will continue looking for one. If a proper closing identifier is not found before the end of the current file, a parse error will result at the last line.

Heredocs不能用于初始化类属性.从PHP 5.3开始,此限制仅对包含变量的heredocs有效...

Heredocs can not be used for initializing class properties. Since PHP 5.3, this limitation is valid only for heredocs containing variables...

这篇关于&lt;&lt;&lt; END在PHP中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆