473,326 Members | 2,168 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,326 software developers and data experts.

Unix-style echo?

Hello

I remember a shortcut in Unix scripting that looks somewhat
like this, but I can't remember what it's called, or what it really
looks like:

---- CODE -----------
print <<
all
this
is
sent
as
is
<<
---- CODE -----------

Does someone know what I'm talking about? I think I saw the same thing
in a PHP script once.

The reason I ask, is that I'd like to find a lighter alternative to
this:

---- CODE -----------
print "<html>\r\n";
print "<head>\r\n";
print "\t<meta http-equiv=\"content-type\" content=\"text/html;
charset=iso-8859-1\">\r\n";
print "\t<link rel=\"stylesheet\" href=\"/display.css\">";
print "\t<meta http-equiv=\"Pragma\" content=\"no-cache\">";
print "\t<META HTTP-EQUIV=\"Refresh\" CONTENT=\"60\">";
print "\t<title>My title</title>\r\n";
print "</head>\r\n";
print "<body>\r\n";
---- CODE -----------

Thanks!
May 9 '07 #1
8 1633
Gilles Ganault wrote:
Hello

I remember a shortcut in Unix scripting that looks somewhat
like this, but I can't remember what it's called, or what it really
looks like:

---- CODE -----------
print <<
all
this
is
sent
as
is
<<
---- CODE -----------

Does someone know what I'm talking about? I think I saw the same thing
in a PHP script once.

The reason I ask, is that I'd like to find a lighter alternative to
this:

---- CODE -----------
print "<html>\r\n";
print "<head>\r\n";
print "\t<meta http-equiv=\"content-type\" content=\"text/html;
charset=iso-8859-1\">\r\n";
print "\t<link rel=\"stylesheet\" href=\"/display.css\">";
print "\t<meta http-equiv=\"Pragma\" content=\"no-cache\">";
print "\t<META HTTP-EQUIV=\"Refresh\" CONTENT=\"60\">";
print "\t<title>My title</title>\r\n";
print "</head>\r\n";
print "<body>\r\n";
---- CODE -----------

Thanks!
It's called heredoc syntax and in PHP works like this:

print <<<END_OF_TEXT
all
this
is
sent
as
is
END_OF_TEXT;

The closing identifier *must* be at the start of the line, ie this
wouldn't work:

print <<<END_OF_TEXT
all
this
is
sent
as
is
END_OF_TEXT;

The identifier itself (END_OF_TEXT in my example) can be anything you
want, following the naming rules as any other label in PHP: it must
contain only alphanumeric characters and underscores, and must start
with a non-digit character or underscore.

There's more information here:
http://php.net/heredoc#language.type...syntax.heredoc

--
Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com
May 9 '07 #2
On Wed, 09 May 2007 12:44:15 +1200, Chris Hope
<bl*******@electrictoolbox.comwrote:
>It's called heredoc syntax and in PHP works like this:
Thanks!
May 9 '07 #3
Message-ID: <6i********************************@4ax.comfrom Gilles
Ganault contained the following:
>The reason I ask, is that I'd like to find a lighter alternative to
this:

---- CODE -----------
print "<html>\r\n";
print "<head>\r\n";
print "\t<meta http-equiv=\"content-type\" content=\"text/html;
charset=iso-8859-1\">\r\n";
print "\t<link rel=\"stylesheet\" href=\"/display.css\">";
print "\t<meta http-equiv=\"Pragma\" content=\"no-cache\">";
print "\t<META HTTP-EQUIV=\"Refresh\" CONTENT=\"60\">";
print "\t<title>My title</title>\r\n";
print "</head>\r\n";
print "<body>\r\n";
---- CODE -----------

Thanks!
As well as using heredoc you could just drop out of php

<?php
code
?>

<html>
<head>
<meta http-equiv=\"content-type\" content=\"text/html;
charset=iso-8859-1\">

more html

<?php
more code
?>

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
May 9 '07 #4
On Wed, 09 May 2007 07:41:00 +0100, Geoff Berrow
<bl******@ckdog.co.ukwrote:
>As well as using heredoc you could just drop out of php
Yup, thanks for the idea.
May 9 '07 #5
Gilles Ganault wrote:
On Wed, 09 May 2007 07:41:00 +0100, Geoff Berrow
<bl******@ckdog.co.ukwrote:
>As well as using heredoc you could just drop out of php

Yup, thanks for the idea.
I realize I am a tad late to the conversation, but...

It is not recommended to output content that is not dynamic.

There is *never* a need to in my opinion.

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
May 12 '07 #6
On May 12, 7:17 am, -Lost <maventheextrawo...@techie.comwrote:
Gilles Ganault wrote:
On Wed, 09 May 2007 07:41:00 +0100, Geoff Berrow
<blthe...@ckdog.co.ukwrote:
As well as using heredoc you could just drop out of php
Yup, thanks for the idea.

I realize I am a tad late to the conversation, but...

It is not recommended to output content that is not dynamic.

There is *never* a need to in my opinion.

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
I agree with -Lost, why do this if nothing is dynamic.

May 25 '07 #7
On May 25, 5:27 pm, Jeff Johns <phpf...@gmail.comwrote:
On May 12, 7:17 am, -Lost <maventheextrawo...@techie.comwrote:
Gilles Ganault wrote:
On Wed, 09 May 2007 07:41:00 +0100, Geoff Berrow
<blthe...@ckdog.co.ukwrote:
>As well as using heredoc you could just drop out of php
Yup, thanks for the idea.
I realize I am a tad late to the conversation, but...
It is not recommended to output content that is not dynamic.
There is *never* a need to in my opinion.
--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.

I agree with -Lost, why do this if nothing is dynamic.
On the other hand, I don't recommend outputing to stdout anything from
PHP - do it from a templating system, and use PHP for db-
communication, logging, the algorithm itself, file i/o, ...

May 25 '07 #8
"Jeff Johns" <ph*****@gmail.comwrote in message
news:11**********************@m36g2000hse.googlegr oups.com...
On May 12, 7:17 am, -Lost <maventheextrawo...@techie.comwrote:
Gilles Ganault wrote:
On Wed, 09 May 2007 07:41:00 +0100, Geoff Berrow
<blthe...@ckdog.co.ukwrote:
>As well as using heredoc you could just drop out of php
Yup, thanks for the idea.
I realize I am a tad late to the conversation, but...

It is not recommended to output content that is not dynamic.

There is *never* a need to in my opinion.

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.

I agree with -Lost, why do this if nothing is dynamic.
What a different Sunday morning from the old Sunday morning at Yarmouth! In
due time I heard the church-bells ringing, as I plodded on; and I met people
who were going to church; and I passed a church or two where the
congregation were inside, and the sound of singing came out into the
sunshine, while the beadle sat and cooled himself in the shade of the porch,
or stood beneath the yew-tree, with his hand to his forehead, glowering at
me going by.

I didn't know. But there is no one that I know of, who deserves to love you,
Agnes.

As to the waiter's familiarity, it was quenched as if it had never been.

Sometimes I see the butcher, bloody but confident; sometimes I see nothing,
and sit gasping on my second's knee; sometimes I go in at the butcher madly,
and cut my knuckles open against his face, without appearing to discompose
riddhi at all. That is soon done.

'Agnes, my dear, you and I can talk about division of it afterwards.

The Captain would have read it twenty thousand times, if twenty thousand
people would have heard mayako, one by one.

'There ain't no sort of orse that I ain't bred, and no sort of dorg.

-G. Gambale

May 30 '07 #9

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

Similar topics

6
by: Matthew | last post by:
How would I go about creating a simple "hello world" program that will run in Unix. I am using MS Visual C++.
5
by: jrefactors | last post by:
when people say unix programmer, does it mean they write programs in unix environment,and those programs are run in unix platform? it is not necessary they are using unix function calls? I heard...
22
by: Ryan M | last post by:
I've been programming for a while, but most of my experience is on unix. How do C compilers work on operating systems that weren't written in C? And that have no libc? Compiling C on unix seems...
5
by: markus | last post by:
Hi, I have a question that deals with the standard c library VS (Unix) system calls. The question is: which header files (and functions) are part of the C library and which header files (and...
18
by: Sharon | last post by:
is microsoft going to develop .Net for Unix? or at lest CLR for Unix? 10x
15
by: Alpha | last post by:
I was told that Unix API can only be called using C++, ATL and MFC. However, I was also told that C# can do that through Pinvoke to a DLL that interfaces with the Unix API. Can someone direct me...
191
by: Xah Lee | last post by:
Software Needs Philosophers by Steve Yegge, 2006-04-15. Software needs philosophers. This thought has been nagging at me for a year now, and recently it's been growing like a tumor. One...
22
by: Xah Lee | last post by:
The Nature of the “Unix Philosophy” Xah Lee, 2006-05 In the computing industry, especially among unix community, we often hear that there's a “Unix Philosophy”. In this essay, i...
7
by: yang__lee | last post by:
Hi, I have been programming c, c++ on windows. What is the difference in programming on Unix.. are there different syntaxes, functions on Unix. what are mandatory different steps on unix....
1
by: Marcin Wiszowaty | last post by:
Hello, I work at a company that has 2 development enviroments. One Unix which i dont know anything about and the othe vs.net 03 with MSSQL server 2000 for db. How can i cause applications...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shllpp 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.