I have seen the <<< operator many times , but I can't find any mention of this operator in PHP documentation. Can anyone please tell what this operator exactly does?
Asked
Active
Viewed 134 times
0
-
HEREDOC, show an example of where uu saw it – Ibu Jun 17 '11 at 05:09
-
@Ibu: what an example would change ))) It always behaves in the same way, like it is explained in documentation. – zerkms Jun 17 '11 at 05:10
-
possible duplicate of [Reference - What does this symbol mean in PHP?](http://stackoverflow.com/questions/3737139/reference-what-does-this-symbol-mean-in-php) – deceze Jun 17 '11 at 05:11
-
@zerkms Just want to provide a specific explanation. – Ibu Jun 17 '11 at 05:12
-
@Ibu: heredoc is as simple as `+`, so for every developer manual should be enough – zerkms Jun 17 '11 at 05:13
3 Answers
3
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.

Dave
- 28,833
- 23
- 113
- 183
1
Here is one place where it is used
$longString = <<<STR
This is a String and this method of creating it is called HEREDOC
STR;

Ibu
- 42,752
- 13
- 76
- 103
0
<<<
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

deceze
- 510,633
- 85
- 743
- 889