Re: Redirecting STDOUT to a file pointer
| From: | Jeff Bearer | Date: | Fri, 28 Feb 2003 20:29:53 +0000 |
| Subject: | Re: Redirecting STDOUT to a file pointer | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-137623@lists.php.net to get a copy of this message | ||
Argh, I was thinking about the problem backwards, redirect the fp to stdout
is the way to do it.
if(!$argv[1]) $argv[1] = "php://stdout";
$fp = fopen($argv[1], "w");
fputs($fp,"blah\n");
fclose($fp);
On Fri, 2003-02-28 at 15:11, Jeff Bearer wrote:
> I'm working on a shell script in php. The script has an option to write
> to standard output, or to a file. If the filehandle is opened I'd like
> to redirect standard output to the file pointer. This would allow me
> not to have to handle every output statement twice, once with an echo
> and again with an fputs.
>
> Can this be done in PHP?
>
>
> --
> Jeff Bearer, RHCE
> Webmaster, PittsburghLIVE.com
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--
Jeff Bearer, RHCE
Webmaster, PittsburghLIVE.com