Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old April 13th, 2007, 09:35 PM
ken
Guest
 
Posts: n/a
Default limit output to only php print/echo statements?

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
  #2  
Old April 14th, 2007, 01:45 AM
petersprc
Guest
 
Posts: n/a
Default Re: limit output to only php print/echo statements?

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:
Quote:
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

  #3  
Old April 14th, 2007, 03:05 AM
Jerry Stuckle
Guest
 
Posts: n/a
Default Re: limit output to only php print/echo statements?

ken wrote:
Quote:
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.
jstucklex@attglobal.net
==================
  #4  
Old April 14th, 2007, 10:35 PM
C.
Guest
 
Posts: n/a
Default Re: limit output to only php print/echo statements?

On 14 Apr, 03:58, Jerry Stuckle <jstuck...@attglobal.netwrote:
Quote:
ken wrote:
Quote:
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.
>
Quote:
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.
>
Quote:
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.
>
Quote:
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.
>
Quote:
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.

  #5  
Old April 14th, 2007, 11:35 PM
Jerry Stuckle
Guest
 
Posts: n/a
Default Re: limit output to only php print/echo statements?

C. wrote:
Quote:
On 14 Apr, 03:58, Jerry Stuckle <jstuck...@attglobal.netwrote:
Quote:
>ken wrote:
Quote:
>>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.
jstucklex@attglobal.net
==================
  #6  
Old April 15th, 2007, 04:45 PM
Mary Pegg
Guest
 
Posts: n/a
Default Re: limit output to only php print/echo statements?

ken wrote:
Quote:
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".
  #7  
Old April 16th, 2007, 06:25 PM
ken
Guest
 
Posts: n/a
Default Re: limit output to only php print/echo statements?

Mary Pegg wrote:
Quote:
ken wrote:
>
Quote:
>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
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles