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

limit output to only php print/echo statements?

ken
is there a way to make a php page only output content that is generated
from php statements, such as print, or echo? ie: if I have whitespace
(or other text) outside my <?php .... ?block i do not want that to be
returned.

of course i can do this by making sure my php file starts with <?php and
ends with ?and there is no leading or trailing whitespace. but if
whitespace does creep into my file then it would be neat if there was
some kind of directive or something that would make sure it doesn't get
output.

i ask this because the output from my script will be interpreted by
another program so i want the output to be specific space delimited
values with no leading/trailing whitespace.

of course i should probably just output my content in xml format and
make my interpreting program parse xml, which accommodates for
whitespace... but... that would be smart, which i am not.

thanks!
ken
Apr 13 '07 #1
6 2369
Hi,

Like you said, keeping the file trimmed is the easiest way. You could
also try using output buffering (ob_start), and trimming the result.

On Apr 13, 4:31 pm, ken <k...@nospam.comwrote:
is there a way to make a php page only output content that is generated
from php statements, such as print, or echo? ie: if I have whitespace
(or other text) outside my <?php .... ?block i do not want that to be
returned.

of course i can do this by making sure my php file starts with <?php and
ends with ?and there is no leading or trailing whitespace. but if
whitespace does creep into my file then it would be neat if there was
some kind of directive or something that would make sure it doesn't get
output.

i ask this because the output from my script will be interpreted by
another program so i want the output to be specific space delimited
values with no leading/trailing whitespace.

of course i should probably just output my content in xml format and
make my interpreting program parse xml, which accommodates for
whitespace... but... that would be smart, which i am not.

thanks!
ken

Apr 14 '07 #2
ken wrote:
is there a way to make a php page only output content that is generated
from php statements, such as print, or echo? ie: if I have whitespace
(or other text) outside my <?php .... ?block i do not want that to be
returned.

of course i can do this by making sure my php file starts with <?php and
ends with ?and there is no leading or trailing whitespace. but if
whitespace does creep into my file then it would be neat if there was
some kind of directive or something that would make sure it doesn't get
output.

i ask this because the output from my script will be interpreted by
another program so i want the output to be specific space delimited
values with no leading/trailing whitespace.

of course i should probably just output my content in xml format and
make my interpreting program parse xml, which accommodates for
whitespace... but... that would be smart, which i am not.

thanks!
ken
No. PHP has no control over what's outside the <?php and ?tags.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 14 '07 #3
C.
On 14 Apr, 03:58, Jerry Stuckle <jstuck...@attglobal.netwrote:
ken wrote:
is there a way to make a php page only output content that is generated
from php statements, such as print, or echo? ie: if I have whitespace
(or other text) outside my <?php .... ?block i do not want that to be
returned.
of course i can do this by making sure my php file starts with <?php and
ends with ?and there is no leading or trailing whitespace. but if
whitespace does creep into my file then it would be neat if there was
some kind of directive or something that would make sure it doesn't get
output.
i ask this because the output from my script will be interpreted by
another program so i want the output to be specific space delimited
values with no leading/trailing whitespace.
of course i should probably just output my content in xml format and
make my interpreting program parse xml, which accommodates for
whitespace... but... that would be smart, which i am not.
thanks!
ken

No. PHP has no control over what's outside the <?php and ?tags.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================

Not necessarily true. There's nothing to stop you writing a filter (in
PHP or other language) which processes a PHP script to return just the
PHP code, and then pass that through the interpreter - and with
mod_rewrite it could all be done transparently. But its not the way to
solve the OPs problem.

C.

Apr 14 '07 #4
C. wrote:
On 14 Apr, 03:58, Jerry Stuckle <jstuck...@attglobal.netwrote:
>ken wrote:
>>is there a way to make a php page only output content that is generated
from php statements, such as print, or echo? ie: if I have whitespace
(or other text) outside my <?php .... ?block i do not want that to be
returned.
of course i can do this by making sure my php file starts with <?php and
ends with ?and there is no leading or trailing whitespace. but if
whitespace does creep into my file then it would be neat if there was
some kind of directive or something that would make sure it doesn't get
output.
i ask this because the output from my script will be interpreted by
another program so i want the output to be specific space delimited
values with no leading/trailing whitespace.
of course i should probably just output my content in xml format and
make my interpreting program parse xml, which accommodates for
whitespace... but... that would be smart, which i am not.
thanks!
ken
No. PHP has no control over what's outside the <?php and ?tags.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================


Not necessarily true. There's nothing to stop you writing a filter (in
PHP or other language) which processes a PHP script to return just the
PHP code, and then pass that through the interpreter - and with
mod_rewrite it could all be done transparently. But its not the way to
solve the OPs problem.

C.
Exactly true. In your case you're using PHP to filter a file. It does
not mean that PHP has any control over what's outside the <?php and ?>
tags. It means you're using a language (it could be ANY language) to
modify the text.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 14 '07 #5
ken wrote:
is there a way to make a php page only output content that is generated
from php statements, such as print, or echo? ie: if I have whitespace
(or other text) outside my <?php .... ?block i do not want that to be
returned.

of course i can do this by making sure my php file starts with <?php and
ends with ?and there is no leading or trailing whitespace.
Make sure there's no leading whitespace (which is pretty obvious) and
simply leave off the ?at the end.

--
"Checking identity papers is a complete waste of time. If anyone can
be counted on to have valid papers, it will be the terrorists".
Apr 15 '07 #6
ken
Mary Pegg wrote:
ken wrote:
>is there a way to make a php page only output content that is generated
from php statements, such as print, or echo? ie: if I have whitespace
(or other text) outside my <?php .... ?block i do not want that to be
returned.

of course i can do this by making sure my php file starts with <?php and
ends with ?and there is no leading or trailing whitespace.

Make sure there's no leading whitespace (which is pretty obvious) and
simply leave off the ?at the end.
great suggestion. totally works.
thanks!
ken
Apr 16 '07 #7

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

Similar topics

3
by: mmccaws | last post by:
Thanks ahead for your help I'm trying to learn what I can do with echo and print statements. I figured out the echo statement and below is the simple version using print. I've tried two dozen...
2
by: Bob | last post by:
Everybody, I've been doing a lot of on-line research and cannot find any reference to the exact problem I'm having. Let me preface this question with the fact that I'm coming from an Oracle...
3
by: Marcus | last post by:
Is there something that can be set in SQL to not print output to the screen? Something like SET NOCOUNT ON, only in this case, I don't want it to print any output except what my script specifies...
5
by: Jay Chan | last post by:
I am trying to use a command line program to run a stored procedure that generates output in a comma-delimitted format. Somehow, ISQL or OSQL always wrap the lines at 256 characters. I believe this...
1
by: Luke Wu | last post by:
I have been using the getline function from K&R2 for simple character input. The prototype is int getline(char *s, int limit); /* returns 0 to signal EOF */ This function simply calls...
27
by: ted benedict | last post by:
hi everybody, i hope this is the right place to discuss this weird behaviour. i am getting dynamically generated text or xml from the server side using xmlhttprequest. if the server side data is...
5
by: Jefferis NoSpamme | last post by:
Hi all, I'm trying to limit the file size of an image submission and I keep running into various problems. I've got most of it working, but I'm stumped and I have a basic question as to WHY this...
3
by: Sandman | last post by:
Hello, I'm building a website in PHP and Javascript. The registration portion is divided into 2 sections: 1. In one, I get info about the visitor. This is sent via POST to a php script which is...
2
by: peridian | last post by:
I've gotten a really weird result crop up on my site, and I can't find any information on the web that it has been seen elsewhere. Given how weird this is, I guess it's probably a symptom of either...
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
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
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
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...

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.