Heredoc is a strange but necessary way to create a complex string. The functionality provided is almost identical to double quoted strings except there are no quotes.
The heredoc syntax uses the special operator ‘<<<' followed by a user defined identifier. The same identifier on a new line must be used to close the string followed by an optional semicolon. This identifier is restricted by the same rules as a regular variable name.
-
-
$what = "Certification";
-
echo <<<TEXT
-
Zend PHP "$what"
-
TEXT;
-
This will output ‘Zend PHP “Certification”‘.
Heredoc syntax can not be used for initializing class properties. Since PHP 5.3, this limitation is valid only for heredocs containing variables.