473,946 Members | 2,034 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1567
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.comman dline.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.ph p>:
"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.comwro te:
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.comman dline.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.ph p>:
"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.comwro te:
>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
2185
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 refresh several times and it keeps happening. When I view page source, the last thing that shows up is the "...". The date doesn't print, nor does the closing the div tag.
3
2697
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 code on IIS 5.0, Win 2000, PHP 4.3.3, in file LH_Svc.php: <?php $resp = "<response>\r\n"; $respLen = strlen ($resp);
6
2398
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 need to see some value. Example i have tables like this echo '<div align="',$align,'"><table border="0" cellpadding="2" cellspacing="0" width="',$largeur,'">'; echo '<tr><td bgcolor="',$titre_bgcolor,'"><font face="',$titre_face,'"...
9
3430
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
2070
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
5235
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 controls. However, even though I turned Echo off, I'm still getting #Name? until I reset the recordset. Here's the code I'm using: DoCmd.Hourglass True Application.Echo False Me.RecordSource = "" <run queries here>
4
2023
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 populated with the data from the query (in theory)!!! But I get a blank page! I have error reporting on php and mysql but nothing is displayed? <?php echo "<form method=\"post\" action=\"\" style=\"padding-left: 10px\">"; ...
11
1872
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. echo "error is $error";
32
2675
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 use a php session cookie to stop the repeating of an embedded video file on a per session basis; i amended the php code to display a still pic if the session cookie value
0
10149
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9974
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11549
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11140
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11320
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10679
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7402
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6317
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4928
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.