You are here: Re: How to write PHP standard output on a text file? « PHP Programming Language « IT news, forums, messages
Re: How to write PHP standard output on a text file?

Posted by d on 11/15/17 11:40

<francescomoi@usa.com> wrote in message
news:1139593886.094217.64410@g43g2000cwa.googlegroups.com...
> Hi.
>
> Using PHP 4.3.11, I want my script not to write standard output on the
> webpage, but
> on a textfile.
>
> I tried with:
>
> [code]
> $variableName = 44;
> system("/usr/local/php/bin/php /home/foo/script.php >
> /home/foo/file.txt", $retval);
> [/code]
>
> But '/home/foo/script.php' doesn't consider $variableName.
>
> Is there any way to call '/home/foo/script.php' and make it to write
> standard output
> on a textfile?
>
> Thank you very much.
>

Use output buffering:

ob_start();
system("/bin/date");
$c=ob_get_contents();
ob_end_clean();
$fp=fopen("/home/foo/file.txt", "wb");
fwrite($fp, $c);
fclose($fp);

The ob_start() causes all the output of the script to be stored in a buffer,
which you have access to.

http://www.php.net/outcontrol

hope that helps!

dave

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация