开发者

Using <<<CON in PHP

What is the effect of the following code?

$page = <<<CON
<p><center>Blah blah blah</center></p>
CON;

What does the <<<CON开发者_C百科 do?


This is known as heredoc. It's essentially a way of defining the value of a variable that spans multiple lines, and doesn't require escaping like traditional strings. The "CON" part is merely an identifier that represents the start and end of the value. This can be changed to a more familiar value.

$str = <<<EOD
Example of string
spanning multiple lines
using heredoc syntax.
EOD;


That's the PHP heredoc operator. Details at this link:

http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜