Re: execute PHP -> return output to string
> ...[color=blue]
>
> ob_start(); // start trapping output
> include "foo.php"; // produce output
> $output = ob_getcontents( ); // get contents of trapped output
> ob_end_clean(); // discard trapped output and stop trapping
>
> ...[/color]
Exactly this is what I did so far before I realized, that the output buffer
is limited in size to 'output_bufferi ng' in the php configuration, which is
set to 4096 bytes by default, but 4K is just not enough for me. I need it do
be unlimited. This could be done with 'output_bufferi ng = On', which limits
the buffer to the RAM size for the script offered in 'memory_limit' (8M by
default).
PS: It must be done this way to make sure everything in the buffer before is
reinsert afterwards.
$old=ob_get_con tents(); ob_clean(); ob_start(); // you may leave ob_start();
include ...;
$out=ob_get_con tents(); ob_clean();
echo $old;
execute PHP -> return output to string
Collapse
This topic is closed.
X
X
-
Guest replied -
Guest repliedRe: execute PHP -> return output to string
Eric Ellsworth wrote:[color=blue]
> See http://us3.php.net/manual/en/function.include.php
>[/color]
to clarify...
ob_start(); // start trapping output
include "foo.php"; // produce output
$output = ob_getcontents( ); // get contents of trapped output
ob_end_clean(); // discard trapped output and stop trapping
cool thing is you can nest these too :)
you can do other things using a call-back. pretty funky stuff really :)
See "output buffering", check the spelling of those functions. I'm too
lazy to look it up...
Leave a comment:
-
Guest repliedRe: execute PHP -> return output to string
See http://us3.php.net/manual/en/function.include.php
"Christophe r-Robin" <Christopher-Robin@gmx.de> wrote in message
news:bobqak$1d4 m4q$1@ID-157729.news.uni-berlin.de...[color=blue]
> Hi
>
> I've got a problem and I hope someone can help me:
>
> I want a PHP script to call another PHP script, execute it and return its
> OUTPUT (not its content) into a STRING in the first script.
>
> --
> _/_/ ICQ: 114034537 IRC : Robin479m (DALnet/EFnet)
> _/ _/ Y! : Robin479m Mail: Christopher-Robin@gmx.de
> _/_/ AIM: Robin479m MSN : Robin479m@hotma il.com
>
>[/color]
Leave a comment:
-
Guest repliedRe: execute PHP -> return output to string
"Christophe r-Robin" a écrit le 05/11/2003 :[color=blue]
> Hi
>
> I've got a problem and I hope someone can help me:
>
> I want a PHP script to call another PHP script, execute it and return its
> OUTPUT (not its content) into a STRING in the first script.[/color]
Don't really understand can't you use function() ?
Leave a comment:
-
execute PHP -> return output to string
Hi
I've got a problem and I hope someone can help me:
I want a PHP script to call another PHP script, execute it and return its
OUTPUT (not its content) into a STRING in the first script.
--
_/_/ ICQ: 114034537 IRC : Robin479m (DALnet/EFnet)
_/ _/ Y! : Robin479m Mail: Christopher-Robin@gmx.de
_/_/ AIM: Robin479m MSN : Robin479m@hotma il.com
Tags: None
Leave a comment: