473,408 Members | 1,739 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,408 software developers and data experts.

how is echo implemented in php

When used with the command line interface, echo writes to the stdout,
whereas in a Web environment, it writes to the response stream. How is
it implemented inside PHP?

Does it write to a stream?

Aug 14 '07 #1
6 1550
Rik
On Tue, 14 Aug 2007 22:58:40 +0200, Water Cooler v2 <wt*****@yahoo.com>
wrote:
When used with the command line interface, echo writes to the stdout,
whereas in a Web environment, it writes to the response stream. How is
it implemented inside PHP?
I really couldn't tell you, to see how it is emplemented exactly you'll
have to take a look at the source I suppose. For more information how it
works on the command line:
<http://nl3.php.net/manual/en/features.commandline.php>
Does it write to a stream?
Well, everything in PHP can be reached 'as a stream', how the inner
workings are is offcourse a different story. This tidbit of information
leads me to believe it is just written to the output stream, where this is
actually directed is not really decided there:

<http://nl3.php.net/manual/en/wrappers.php.php>:
"php://output allows you to write to the output buffer mechanism in the
same way as print() and echo()."
--
Rik Wasmus
Aug 14 '07 #2
On Aug 15, 2:14 am, Rik <luiheidsgoe...@hotmail.comwrote:
On Tue, 14 Aug 2007 22:58:40 +0200, Water Cooler v2 <wtr_...@yahoo.com>
wrote:
When used with the command line interface, echo writes to the stdout,
whereas in a Web environment, it writes to the response stream. How is
it implemented inside PHP?

I really couldn't tell you, to see how it is emplemented exactly you'll
have to take a look at the source I suppose. For more information how it
works on the command line:
<http://nl3.php.net/manual/en/features.commandline.php>
Does it write to a stream?

Well, everything in PHP can be reached 'as a stream', how the inner
workings are is offcourse a different story. This tidbit of information
leads me to believe it is just written to the output stream, where this is
actually directed is not really decided there:

<http://nl3.php.net/manual/en/wrappers.php.php>:
"php://output allows you to write to the output buffer mechanism in the
same way as print() and echo()."
--
Rik Wasmus

I downloaded the source on my Windows XP Pro machine. Can you please
tell me in which folder I can find the definition of the function?

Aug 14 '07 #3
On Tue, 14 Aug 2007 13:58:40 -0700, Water Cooler v2 wrote:
When used with the command line interface, echo writes to the stdout,
whereas in a Web environment, it writes to the response stream. How is
it implemented inside PHP?

Does it write to a stream?
I'm assuming it's written to stdout no matter where it's run... as with
CGI applications, the browser interface IS stdout and the webserver
controls where the output goes.
Aug 14 '07 #4
Rik
On Tue, 14 Aug 2007 23:17:52 +0200, Water Cooler v2 <wt*****@yahoo.com>
wrote:
On Aug 15, 2:14 am, Rik <luiheidsgoe...@hotmail.comwrote:
>On Tue, 14 Aug 2007 22:58:40 +0200, Water Cooler v2 <wtr_...@yahoo.com>
wrote:
When used with the command line interface, echo writes to the stdout,
whereas in a Web environment, it writes to the response stream. How is
it implemented inside PHP?

I really couldn't tell you, to see how it is emplemented exactly you'll
have to take a look at the source I suppose.

I downloaded the source on my Windows XP Pro machine. Can you please
tell me in which folder I can find the definition of the function?
It is not a function, it's a language construct. And sorry, can't tell you
where to find it, you'll have to search for it yourself, or possibly ask
one of the developers.
--
Rik Wasmus
Aug 14 '07 #5
On 14.08.2007 22:58 Water Cooler v2 wrote:
When used with the command line interface, echo writes to the stdout,
whereas in a Web environment, it writes to the response stream. How is
it implemented inside PHP?

Does it write to a stream?
If you interested in php internals, I'd recommend browsing their LXR
site. For 'echo', start here

http://lxr.php.net/source/ZendEngine2/zend_vm_def.h#883

and follow the links.

--
gosha bine

makrell ~ http://www.tagarga.com/blok/makrell
php done right ;) http://code.google.com/p/pihipi
Aug 15 '07 #6
Ivan Marsh wrote:
I'm assuming it's written to stdout no matter where it's run... as with
CGI applications, the browser interface IS stdout and the webserver
controls where the output goes.
That would be my assumption too, which the added note that on Apache,
mod_php hooks into the web server itself, so probably has something to do
with informing Apache that stdout should be sent to the HTTP client.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 55 days, 11:51.]

Fake Steve is Dead; Long Live Fake Bob!
http://tobyinkster.co.uk/blog/2007/08/13/fake-bob/
Aug 15 '07 #7

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

Similar topics

2
by: lawrence | last post by:
Right now, over at www.monkeyclaus.org, the following script is getting to the 9th run through and dying after the line: echo "..."; You'll admit that is a strange place to die. I've hit...
3
by: Michael Flanagan | last post by:
Of course "echo" is working, but I've got a case where php doesn't seem to be sending out the result of an "echo." I'm probably doing something wrong, but I can't see it. I've got the following...
6
by: Marco | last post by:
I have a couple pages that have tables, whats best use echo to produce the full table with the variables or is it best to just make the table in plain html and use <?php echo ('$va'l); ?> when i...
9
by: Domestos | last post by:
Here an unusual one... Say i am writing a few lines of code in php script as so... <?php echo '<table>'; echo '<tr>'; echo '<td> blah blah </td>'; echo '</tr>'; echo '</table>';
9
by: windandwaves | last post by:
Hi Folk My question is: echo all the time vs echo at the end - what is faster Let me explain I used to write pages like this: echo "<head> ";
11
by: Neil | last post by:
I need to temporarily remove the recordset from my form while I run some queries (have locking problems). So I turned Echo off before removing the recordset to avoid getting #Name? in the bound...
4
by: rawky1976 | last post by:
Hi, I have a hyperlink which goes to the page below and passes the PK_ID from a query into 'userid'. From this we query the DB and then echo a table with a form; only the textboxes are already...
11
by: Twayne | last post by:
Hi, Irrelevant question time, probably: Is there any advantage/reason to use one format over the other for the following two types of echo statements? 1. echo "error is " . $error; 2. ...
32
by: Request-1 | last post by:
hi folks, html coder here, new and terrified * of php!! aaaaaa! i'm trying to bury a JS script to rotate a photo, in a page i converted from html to php. the conversion went well, it was to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.