Heredoc provides an alternative way of defining strings in PHP. They are particularly useful when we need to define a string over multiple lines. They work by defining an identifier that will mark the start and end of the string. The identifier can be any alphanumeric value following the same rules we’d use for variable names. One important thing to note with the identifier is that as of PHP 7.3 you need to make sure that it does not appear within the string itself.

Basic concept of HEREDOC

echo <<<EOT
Hello World.
Goodbye!
EOT;
// Output:-
// Hello World.
// Goodbye!


In SQL, it can be used as following

$sql = <<<SQL
select * from basictable
SQL;