By: Emiley J. Printer Friendly Format
Here-docs enable you to embed large pieces of text in your scripts, which may include lots of double quotes and single quotes, without having to constantly escape them.
The following is an example of a here-doc:
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 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.
Most Viewed Articles (in PHP )
Latest Articles (in PHP)
Comment on this tutorial
- Data Science
- Cloud Computing
- Java Beans
- Mac OS X
- Office 365
- Tech Reviews