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

How not to send headers?

Let me explain my situation:

I have a PHP app that generates web pages on the fly based on some data
it reads from XML files. The pages are served up via a http server and
displayed with a browser.

I've been asked to port this to an ANSI terminal-type display,
eliminating the web server and browser.

Initially I thought about using C to write the app, but XML handling in
C is a real PITA, plus I don't get to reuse my PHP code.

So, now I want to use PHP to generate those same pages except that I
don't want to send headers ever, and I need to loop waiting for
characters to arrive from the keypad and display pages based on those
chars...

This is on an embedded platform, and I really need to be able to use a
single PHP binary for both purposes (the displays are interchangeable at
the hardware level; it all depends on what the customer pays for.)

How do I get php to act as just another scripting language?

Thanks,

--Yan
Sep 6 '06 #1
5 2675
On Wed, 06 Sep 2006 10:12:12 -0700, CptDondo <ya*@NsOeSiPnAeMr.comwrote:
>I have a PHP app that generates web pages on the fly based on some data
it reads from XML files. The pages are served up via a http server and
displayed with a browser.

I've been asked to port this to an ANSI terminal-type display,
eliminating the web server and browser.

Initially I thought about using C to write the app, but XML handling in
C is a real PITA, plus I don't get to reuse my PHP code.

So, now I want to use PHP to generate those same pages except that I
don't want to send headers ever, and I need to loop waiting for
characters to arrive from the keypad and display pages based on those
chars...

This is on an embedded platform, and I really need to be able to use a
single PHP binary for both purposes (the displays are interchangeable at
the hardware level; it all depends on what the customer pays for.)

How do I get php to act as just another scripting language?
The CLI executable version of PHP doesn't output headers:

andyh@server ~ $ php test.php
look, no headers!

andyh@server ~ $ php -v
PHP 5.1.5 (cli) (built: Aug 17 2006 21:16:25)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Sep 6 '06 #2
CptDondo wrote:
Let me explain my situation:

I have a PHP app that generates web pages on the fly based on some data
it reads from XML files. The pages are served up via a http server and
displayed with a browser.

I've been asked to port this to an ANSI terminal-type display,
eliminating the web server and browser.

Initially I thought about using C to write the app, but XML handling in
C is a real PITA, plus I don't get to reuse my PHP code.

So, now I want to use PHP to generate those same pages except that I
don't want to send headers ever, and I need to loop waiting for
characters to arrive from the keypad and display pages based on those
chars...

This is on an embedded platform, and I really need to be able to use a
single PHP binary for both purposes (the displays are interchangeable at
the hardware level; it all depends on what the customer pays for.)

How do I get php to act as just another scripting language?

Thanks,

--Yan
Yan,

If you're running on a web server, the headers will always be sent. PHP
doesn't send the headers, the web server does.

You can run it as a batch job, in which case the headers won't be sent.
But while you'll probably be able to use some of the code, you won't
be able to easily make the same program work both ways. At least not
without a lot of if($onwebserver){...} else {...} constructs.

Probably better to create two files and one or more include files for
the code you can use in both.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 6 '06 #3
*** CptDondo escribió/wrote (Wed, 06 Sep 2006 10:12:12 -0700):
I've been asked to port this to an ANSI terminal-type display,
eliminating the web server and browser.
Headers are part of the HTTP protocol. Every piece of software that uses
HTTP *must* understand headers. So (as you mention) you must get rid of
HTTP and write your own server with your own protocol.

I haven't tested myself but this article describes how to create a PHP
script that listens in a TCP port:

http://www.litfuel.net/tutorials/sockets/sockets.php

You will find the full reference (as well as some self-explaining code
snippets) in the "Socket Functions" chapter of the PHP manual.
--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
Sep 6 '06 #4
Jerry Stuckle wrote:
CptDondo wrote:
>Let me explain my situation:

I have a PHP app that generates web pages on the fly based on some
data it reads from XML files. The pages are served up via a http
server and displayed with a browser.

I've been asked to port this to an ANSI terminal-type display,
eliminating the web server and browser.

Initially I thought about using C to write the app, but XML handling
in C is a real PITA, plus I don't get to reuse my PHP code.

So, now I want to use PHP to generate those same pages except that I
don't want to send headers ever, and I need to loop waiting for
characters to arrive from the keypad and display pages based on those
chars...

This is on an embedded platform, and I really need to be able to use a
single PHP binary for both purposes (the displays are interchangeable
at the hardware level; it all depends on what the customer pays for.)

How do I get php to act as just another scripting language?

Thanks,

--Yan

Yan,

If you're running on a web server, the headers will always be sent. PHP
doesn't send the headers, the web server does.
OK, I'll play with it a bit... I've never quite figured the difference
between php-cgi and php-cli. They both seem to do the same thing. As
my embedded system is tipping the scales at 32 MB, I am doing what I can
to eliminate unnecessary bloat....
>
You can run it as a batch job, in which case the headers won't be sent.
But while you'll probably be able to use some of the code, you won't be
able to easily make the same program work both ways. At least not
without a lot of if($onwebserver){...} else {...} constructs.

Probably better to create two files and one or more include files for
the code you can use in both.
Well, the idea was to split the existing code into a front end and a
back end, where the back end does the XML parsing and manipulation, and
the front end handles the display end of things.

That way I can reuse the back end code for both display modes without a
snakes' nest of if ... else... :-)

--Yan
Sep 7 '06 #5
CptDondo wrote:
Jerry Stuckle wrote:
>CptDondo wrote:
>>Let me explain my situation:

I have a PHP app that generates web pages on the fly based on some
data it reads from XML files. The pages are served up via a http
server and displayed with a browser.

I've been asked to port this to an ANSI terminal-type display,
eliminating the web server and browser.

Initially I thought about using C to write the app, but XML handling
in C is a real PITA, plus I don't get to reuse my PHP code.

So, now I want to use PHP to generate those same pages except that I
don't want to send headers ever, and I need to loop waiting for
characters to arrive from the keypad and display pages based on those
chars...

This is on an embedded platform, and I really need to be able to use
a single PHP binary for both purposes (the displays are
interchangeable at the hardware level; it all depends on what the
customer pays for.)

How do I get php to act as just another scripting language?

Thanks,

--Yan


Yan,

If you're running on a web server, the headers will always be sent.
PHP doesn't send the headers, the web server does.


OK, I'll play with it a bit... I've never quite figured the difference
between php-cgi and php-cli. They both seem to do the same thing. As
my embedded system is tipping the scales at 32 MB, I am doing what I can
to eliminate unnecessary bloat....
It's pretty simple. The CGI or web server integrated interface uses the
web server for I/O operations - you don't have to open a socket to the
client, for instance. It also gets additional value from the web server.

The cli version is just that - a command line version. It doesn't run
under the web server; rather it interfaces to the command line directly.
But if you want to talk to a remote system, either that system has to
telnet/ssh into a command line prompt or you have to do your own socket
work.
>>
You can run it as a batch job, in which case the headers won't be
sent. But while you'll probably be able to use some of the code, you
won't be able to easily make the same program work both ways. At
least not without a lot of if($onwebserver){...} else {...} constructs.

Probably better to create two files and one or more include files for
the code you can use in both.


Well, the idea was to split the existing code into a front end and a
back end, where the back end does the XML parsing and manipulation, and
the front end handles the display end of things.

That way I can reuse the back end code for both display modes without a
snakes' nest of if ... else... :-)
No problem with that.
--Yan


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 8 '06 #6

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

Similar topics

4
by: Bob | last post by:
Seem to have a problem ending a session. I get the following message. Warning: session_start(): Cannot send session cookie - headers already sent by (output started at...
1
by: Lakshmi Narayanan.R | last post by:
Hi Experts, In one SMS gateway project i need a great and urgent help from u all. There, the Service Providers sending the data thru "HTTP Headers" (For ex. sms-Id,sms-source ). So i need to...
6
by: Chapman Flack | last post by:
Ok, I've registered all the right headers to send, with header( 'Content-Type: .../...') etc. The next thing to do is exec a program that will be producing the actual content. The content MUST...
2
by: SharpSmith | last post by:
hi all i have a very specific question regarding emails sending and googling doesn't help me is a way exists to send email using .NET framework (System.Web.Mail or something else) and have the...
19
by: lawrence k | last post by:
How can I find out where my script is outputting to the screen for the first time? My error logs are full of stuff like this: PHP Warning: session_start(): Cannot send session cache...
2
by: sufian | last post by:
<input type="image" id="imageField" class="btn" src="<?php bloginfo('template_url'); ?>/media/global/btn-go.gif" onclick = "sendRequestPost(document.getElementById('email1').value);" /> The...
6
by: Harshpandya | last post by:
Hi all, I am working on the form in which you fill out the whole PHP form and e mail that details to someone. It is working fine. But now i want to send the same form to be sent to different...
1
by: Chitu03 | last post by:
Hi I am already send a mail using Php with some attachement into it. My Problem is the attachement file is in my Database(mysql). I don't know how can i get from database and then add to my mail....
0
by: Lars | last post by:
Hi I'm trying to send an email using the following code in an ASP.NET 2.0 form. Can some one tell me why the email doesn\t arrive at the destination and wy the form tries to update but never...
1
by: deepaks85 | last post by:
Dear All, I want to send some data through a form with Multiple attachment in an HTML Format. I have tried it but it is not working for me. I am able to send data without attachment but with the...
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?
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
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...
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...
0
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...

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.