473,387 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

What is <<<HTML?

Saw an example of code recently that used this:

echo <<<HTML
$error $x INVALID DOMAINS<DIV align="center">$display</DIV>
HTML;

I would have done it like:

echo $error.$x."INVALID DOMAINS<DIV
align=\"center\">".$display."</DIV>";

I tried it thos other way, and it output the same info. But what I'm
intrigued by is the fact with this other way, I don't have to escape
quotes!
I have noticed some annoyances like "HTML;" but be completely left
justified or it breaks whatever "<<<HTML" does which can make proper
indentation look odd.

But what exactly is "<<<HTML" and what other uses does it have?
I've been trying to seach it, but Google and Yahoo and MSN all ignore
the <<< so all I get are pages regarding HTML. =/

Thanks for any info!
Liam

Jul 17 '05 #1
4 1525
ne**@celticbear.com wrote:
Saw an example of code recently that used this:

echo <<<HTML
$error $x INVALID DOMAINS<DIV align="center">$display</DIV>
HTML;

I would have done it like:

echo $error.$x."INVALID DOMAINS<DIV
align=\"center\">".$display."</DIV>";

I tried it thos other way, and it output the same info. But what I'm
intrigued by is the fact with this other way, I don't have to escape
quotes!


This is called a "heredoc" and is described at
http://www.php.net/manual/en/language.types.string.php

You can also delimit your strings with single quotes if you don't want
to escape the double quotes:

echo $error . $x . 'INVALID DOMAINS<DIV align="center">' . $display .
'</div>';

Ken

Jul 17 '05 #2
On 23 Jun 2005 13:40:56 -0700, ne**@celticbear.com wrote:
Saw an example of code recently that used this:

echo <<<HTML
$error $x INVALID DOMAINS<DIV align="center">$display</DIV>
HTML;

But what exactly is "<<<HTML" and what other uses does it have?


Search term: heredoc.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #3
On 23 Jun 2005 13:53:24 -0700, "Ken Robinson" <ke******@rbnsn.com> wrote:
You can also delimit your strings with single quotes if you don't want
to escape the double quotes:

echo $error . $x . 'INVALID DOMAINS<DIV align="center">' . $display .
'</div>';


Or use single quotes in the HTML as this is specifically allowed according to
the specs - basically use the opposite sort of quotes inside as on the outside,
to avoid having to slash it.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #4
ne**@celticbear.com wrote:
Saw an example of code recently that used this:

echo <<<HTML
$error $x INVALID DOMAINS<DIV align="center">$display</DIV>
HTML;

I would have done it like:

echo $error.$x."INVALID DOMAINS<DIV
align=\"center\">".$display."</DIV>";
You also don't have to escape the double quotes if you use single quoted
strings. An alternative to your above code would be:

echo $error.$x.'INVALID DOMAINS<DIV
align="center">'.$display.'</div>';

or instead of the concatenation in the middle of the string you could do
it this way:

echo $error.$x."INVALID DOMAINS<DIV
align=\"center\">$display</div>";
I tried it thos other way, and it output the same info. But what I'm
intrigued by is the fact with this other way, I don't have to escape
quotes!
I have noticed some annoyances like "HTML;" but be completely left
justified or it breaks whatever "<<<HTML" does which can make proper
indentation look odd.

But what exactly is "<<<HTML" and what other uses does it have?
I've been trying to seach it, but Google and Yahoo and MSN all ignore
the <<< so all I get are pages regarding HTML. =/


The syntax is called heredoc and can be found in the manual here:
http://www.php.net/manual/en/languag...syntax.heredoc

Note that the delimiter can be anything unique, so for example it could
be:

echo <<<END_OF_HTML

END_OF_HTML;

The closing part must always be at the start of the line and end with a
semi-colon, and there must not be anything else on the line.

--
Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: josh dismukes | last post by:
/// here is the code i'm getting a parse error on the last line of the code which /// is </html> any help will be much appreciated. <?php session_start ();
7
by: Anders S. Clausen | last post by:
Hi I have a jsp with a couple of <HTML:TEXTAREA> where I would like to dynamically size the textarea depending on the length of a String entered on a different jsp. The two new textareas are to...
9
by: Philip TAYLOR | last post by:
Configuring a new instance of IIS, I noticed that it allows an HTML-formatted document trailer to be appended to every document served. Unfortunately, on checking its behaviour, I find that it...
10
by: Kathy Burke | last post by:
Hi, in trying to discover why my RegisterStartUpScript wouldn't work (I do NOT see it in the HTML source), I looked at the HTML source of a page where I do an XslTransform. First, I get the...
2
by: taras.di | last post by:
Hi everyone, Is it possible to place javascript outside of <html> tags? I'm trying it on mozilla atm, and it seems to be working, but I was more worried about the older browsers. Cheers ...
4
by: Mark G. | last post by:
Hello. I am attempting to write a "scraper" to download information from a commercial web site. Oddly enough, they don't want to make this easy for me! Their pages include plenty of Javascript,...
1
by: yawnmoth | last post by:
I'm trying to mess around with PHP5's DOM functions and have run into something that confuses me: <?php $dom = new DOMDocument(); $dom->loadHTML('<html></html>'); echo...
1
by: John | last post by:
Hi var poster="<html><head..... etc .... </html>"; var animal='dog'; The string contains images and text that changes. Originally I wanted to do something like print "<a href=" +...
0
by: ajos | last post by:
hi friends, Im currently having a <html:select> where ive got many options value inside it...for example---> <html:select property="branch" size="1"> <html:option value="New...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.