0

Possible Duplicate:
PHP <<<EOB

I saw this below piece of code in one php file , can some one explain what <<< st means.?

$status['caption']=<<<ST

ST;

P.s : I really cant google it , trust me :D

Community
  • 1
  • 1
Sunita Shivnani
  • 111
  • 1
  • 9

5 Answers5

5

This is referred to as a heredoc string.

Matt S
  • 14,976
  • 6
  • 57
  • 76
4

That is a way to store multiline strings. (Called Heredoc Syntax)

$string = <<<IDENTIFIER



IDENTIFIER;

All the lines in between are stored as string. Used for long walls of text. It is described here.

Anirudh Ramanathan
  • 46,179
  • 22
  • 132
  • 191
4

It is called the Heredoc syntax: http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc

It can be helpful for multiline strings and strings containing both double and single quotes. As double quotes Heredoc interprets many escape sequences for special characters.

Boris D. Teoharov
  • 2,319
  • 4
  • 30
  • 49
3

The <<< operator stands for the heredoc syntax. It's a way to write strings in a natural way.

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

Roberto Maldonado
  • 1,585
  • 14
  • 27
0

That's a heredoc string ("text block").

Everything between <<<ST and ST; will be output as it is written. So you could put some HTML you want to output and save a bunch of print() statements or save your self the work of escaping characters like you would with a $variable = " textity text text text"; command.

From php website : 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, but the escape codes listed above can still be used. Variables are expanded, but the same care must be taken when expressing complex variables inside a heredoc as with strings.

Landjea
  • 384
  • 1
  • 12