Suppose you want to include A LOT of text (like several lines of code) as a String variable, and you don't want to escape all the possible quotation problems. Try this trick (called the Heredoc Syntax):
Now, if you try to echo the variable, you get:
Heredoc text behaves just like a double-quoted string, without the double-quotes. This means that you do not need to escape quotes in your here docs, but you can still use escape codes as elsewhere.
The end identifier (END_CONTENT; in the above example) must be the only thing on the line (it must be preceeded and followed by a '\r' and it must begin at the first character of the line.
Scripts using single quotes run slightly faster because the PHP parser can include the string directly. Double quoted strings are slower because they need to be parsed.
Anatomy of a Class < < PREVIOUS | Table of Contents | NEXT > > Construct Tricks |
![]() |
Sandersongs Web Tutorials Contact the Webmasterwith comments. ©2025, by Bill Sanders, all rights reserved. This domain had 3,616 different visits in the last 30 days. |
http://sandersongs.com/PHPsqlCourse/PHPadv12.php
This page was last modified on our server on 11 Jul 2021 and last refreshed on our server at 5:03 am, UTC This file took 0.00685 seconds to process. |