Skip to content
Advertisement

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

For example:

$sql = <<<MySQL_QUERY

Advertisement

Answer

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;
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement