开发者

What does <<< operator in php exactly do?

I have seen the <<< operator many times , but I can't find any mention of this oper开发者_高级运维ator in PHP documentation. Can anyone please tell what this operator exactly does?


Full explanation here.

With a bit easier explanation here.

Heredoc syntax is a way to delimit strings in PHP (and other languages) with 3 “less than” symbols: <<<.

The good part about it:

Heredoc text behaves just like a double-quoted string, without the double quotes. This means that quotes in a heredoc do not need to be escaped. Variables are expanded, but the same care must be taken when expressing complex variables inside a heredoc as with strings.


Here is one place where it is used

$longString = <<<STR

This is a String and this method of creating it is called HEREDOC

STR;


<<< is the opener for the HEREDOC syntax. You follow it by an arbitrary string which is used as terminator. It's alternative syntax to quotes. See: http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜