Maison  >  Article  >  développement back-end  >  浅谈PHP中的<<<运算符,浅谈php中运算符_PHP教程

浅谈PHP中的<<<运算符,浅谈php中运算符_PHP教程

WBOY
WBOYoriginal
2016-07-12 08:53:29949parcourir

浅谈PHP中的

PHP中提供了

这种方法详细表述了字符串的字面值,并在文本中保留了字符串的下划线和其他空格(包括缩进)。例如:

<&#63;php
$author ='wixy';
echo <<<_END
Thisis a Headline
Thisis the first line.
Thisis the second line.
---Writtenby $author.
_END;
&#63;>

PHP解析器会将两个_END标签中间的所有内容输出,就相当于一个用双引号引用的字符串。
这意味着,我们可以将一整段HTML语言直接写在PHP代码中,然后用PHP变量来替换具体的动态部分。

 <&#63;php
 $out =<<<_END
 .....
 _END;
 &#63;>

也可用上面这种方式将两个标签中的内容赋值给变量。
 
注意:用来关闭的_END标签必须单独放在一行,而且这一行中不能添加其他内容,即使注释或者空格也不允许

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1123847.htmlTechArticle浅谈PHP中的运算符,浅谈php中运算符 PHP中提供了运算符构建多行字符串序列的方法,通常称为here-document或表示为heredoc的简写。 这种方法详...
Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn