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.
©2018, by Bill Sanders, all rights reserved.
This domain had 3,832 different visits in the last 30 days.
456,765 hits on this domain since 24 Nov 2006.
This page was last modified on our server on 4 Jun 2008
and last refreshed on our server at 4:35 am, MST
This file took 0.00998 seconds to process.