OZONE Asylum
FAQ
How do I use the HERE Document?
This page's ID:
5303
Search
QuickChanges
Forums
FAQ
Archives
Register
You are editing "How do I use the HERE Document?"
Who can edit an FAQ?
Anyone registered may edit an FAQ.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
A HERE Document is a Perl idea which is also used in PHP4+ and basically what it allows you to do is create a long string without having to worry about escaping it. Perl will not process anything in between the starting word and its matching ending word (they can be whatever you want as long as they are the same). In Perl there must not be a space between the second left-angle bracket and the starting word, and the starting word must be followed immediately by a semicolon. The ending word must appear on a line by itself with no whitespace on either side -- except for a required newline immediately following it -- and no semicolon: [code] $extra_javascript = <<HERE; <div class="myClass">Normal strings would require that the quotes (") or apostrophes (') would need escaping which in a long string would be time consuming so we use a HERE document.</div> HERE [/code] PHP does things slightly differently (3 <, and the semicolon is move to the last line of the HERE): [code] $extra_javascript = <<< HERE <div class="myClass">Normal strings would require that the quotes (") or apostrophes (') would need escaping which in a long string would be time consuming so we use a HERE document.</div> HERE; [/code] ----------------------------- Relevant links: [url=http://perl.about.com/library/weekly/aa052900d.htm]How to use HERE documents in Perl[/url] [url=http://www.webclass.ru/tut.php?tip=110]"Here document" output style[/url] [url=http://jamhitz.tripod.com/1e.html]Enter the "Here Document"[/url] [url=http://www.zend.com/tips/tips.php?id=174&single=1]PHP 4 Here-Document gotcha[/url] [url=http://www.zend.com/zend/tut/using-strings.php]Using Strings[/url] [url=http://www.php.net/print]print() - PHP manual[/url] [url=http://www.php.net/print]echo() - PHP manual[/url] ______________________ [internallink=4626]Emperor[/internallink] [small][i](Added by: [url=http://www.ozoneasylum.com/cgi-bin/ubbmisc.cgi?action=getbio&UserName=Emperor]Emperor [/url] on Sat 21-Sep-2002)[/i][/small] [small][i](Edited by: [url=http://www.ozoneasylum.com/cgi-bin/ubbmisc.cgi?action=getbio&UserName=Emperor]Emperor [/url] on Sat 21-Sep-2002)[/i][/small] [small][i](Edited by: [url=http://www.ozoneasylum.com/cgi-bin/ubbmisc.cgi?action=getbio&UserName=mrj]mrj [/url] on Sun 19-Jan-2003)[/i][/small] [small][i](Edited by: [url=http://www.ozoneasylum.com/cgi-bin/ubbmisc.cgi?action=getbio&UserName=Emperor]Emperor [/url] on Mon 29-Sep-2003)[/i][/small]
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »