By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,642 Members | 1,687 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,642 IT Pros & Developers. It's quick & easy.

execute PHP -> return output to string

P: n/a
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: Ch***************@gmx.de
_/_/ AIM: Robin479m MSN : Ro*******@hotmail.com
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"Christopher-Robin" a écrit le 05/11/2003 :
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.


Don't really understand can't you use function() ?
Jul 17 '05 #2

P: n/a
See http://us3.php.net/manual/en/function.include.php

"Christopher-Robin" <Ch***************@gmx.de> wrote in message
news:bo*************@ID-157729.news.uni-berlin.de...
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: Ch***************@gmx.de
_/_/ AIM: Robin479m MSN : Ro*******@hotmail.com

Jul 17 '05 #3

P: n/a
Eric Ellsworth wrote:
See http://us3.php.net/manual/en/function.include.php


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...

Jul 17 '05 #4

P: n/a
> ...

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

...


Exactly this is what I did so far before I realized, that the output buffer
is limited in size to 'output_buffering' 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_buffering = 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_contents(); ob_clean(); ob_start(); // you may leave ob_start();
include ...;
$out=ob_get_contents(); ob_clean();
echo $old;
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.