Here-docs (<<<) in PHP
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:
<<<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.
Comment on this tutorial
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Subscribe to Tutorials
Related Tutorials
PHP code to import from CSV file to MySQL
PHP code to write to a CSV file from MySQL query
PHP code to write to a CSV file for Microsoft Applications
Password must include both numeric and alphabetic characters - Magento
PHP file upload prompts authentication for anonymous users
PHP file upload with IIS on windows XP/2000 etc
Error: Length parameter must be greater than 0
Multiple File Upload in PHP using IFRAME
Resume or Pause File Uploads in PHP
Exception in module wampmanager.exe at 000F15A0 in Windows 8