In PHP, what does "<<<" represent?

Chrish picture Chrish · Sep 13, 2010 · Viewed 51.6k times · Source

For example:

$sql = <<<MySQL_QUERY

Answer

tdammers picture tdammers · Sep 13, 2010

That's heredoc syntax. You start a heredoc string by putting <<< plus a token of your choice, and terminate it by putting only the token (and nothing else!) on a new line. As a convenience, there is one exception: you are allowed to add a single semicolon after the end delimiter.

Example:

echo <<<HEREDOC
This is a heredoc string.

Newlines and everything else is preserved.
HEREDOC;