Connecting Tech Pros Worldwide Help | Site Map

limit output to only php print/echo statements?

  #1  
Old April 13th, 2007, 09:35 PM
ken
Guest
 
Posts: n/a
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

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

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

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

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

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

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
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
"error_reporting" setting not being recognized in my php.ini file laredotornado@zipmail.com answers 1 October 3rd, 2006 03:25 PM
xmlhttprequest to get dynamically generated data seems to have a size limit ted benedict answers 27 January 19th, 2006 08:15 AM
php extensions and windows... specifically extension_dir Chris Paul answers 3 December 5th, 2005 12:45 AM
Cannot use mail() in IE, only works in a debugger--help baustin75@gmail.com answers 8 October 5th, 2005 06:15 PM