2012-02-02 95 views
0

可能重复:
Reference - What does this symbol mean in PHP?
What is the name for the “<<<” operator?请解释一下这个PHP代码 “<<< CSS”

我可以推断这是什么做什么,但我需要知道怎么了,可能会找到一些文档。 标题<<<CSS中的表达式似乎设置了一个要插入模板的css块。但是,没有功能可以从这些文本字符串中去除<<<CSS,但它们不会出现。这使我相信<<<不只是一个随机标记,但具有特殊的PHP含义。请帮忙。

if(!empty($background['header_image'])){ 
    $header_image = <<<CSS 
background-image: url('{$background['header_image']}'); 
background-repeat: {$background['header_repeat']}; 
background-position: top {$background['header_position_x']}; 
background-attachment: scroll; 
CSS;` 
+0

我试过在google和这个论坛中搜索'“<<<”operator“。试试看吧。我尝试了“3以下”等等等等。我真的尝试过之前发布。 – DogBot 2012-02-02 22:08:22

回答

3

这就是所谓的heredoc。请参阅PHP documentation

这是一种将多行文本分配给变量的简单方法。

+0

谢谢,就是这样! – DogBot 2012-02-02 22:08:39

2

它被称为定界符:http://www.tuxradar.com/practicalphp/2/6/3

基本上,它说:“插入此字符串后一切< < < CSS,直到您找到自己在一行CSS。”

+0

谢谢,非常有帮助的链接了。 – DogBot 2012-02-02 22:09:51