2.5 Basic Data Types
21
Examples:
‘Hello, World’
‘Today\’s the day’
2.5.3.3 Here-Docs
Here-docs enable you to embed large pieces of text in
your scripts, which may include lots of double quotes and single quotes, with-
out having to constantly escape them.
The following is an example of a here-doc:
<<<THE_END
PHP stands for “PHP: Hypertext Preprocessor”.
The acronym “PHP” is therefore, usually referred to as a recursive acronym
because the long form contains the acronym itself.
As this text is being written in a here-doc there is no need to escape the
double quotes.
THE_END
The strings starts with <<<, followed by a string that you know doesn’t
appear in your text. It is terminated by writing that string at the beginning of
a line, followed by an optional semicolon (;), and then a required newline (\n).
Escaping and variable substitution in here-docs is identical to double-quoted
strings except that you are not required to escape double quotes.
