Re: Standard output (printf) question...

From: Date: Fri, 21 Dec 2001 08:24:21 +0000
Subject: Re: Standard output (printf) question...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-78433@lists.php.net to get a copy of this message
Thanks Richard, I don't think the output buffering does what I want. I want to be able to do something like this: if( $preview_mode ) $output = fopen("php://stdout", "w"); else $output = fopen("/some/file/path/soemwhere.html", "w"); GenerateOutput($output); hmmm.... wait, maybe you're right. I guess I could grab the contents of the output buffer and write it to the file instead of to stdout. Kind of an indirect way of doing it. Not like C/C++. Thanks for the pointer. Richard Black wrote: > > As far as I'm aware PHP does output to stdout. Whether or not we can > actually access that stream is another question, and one I don't know the > answer to. > > However, I do have a suggestion... Have you looked at the output buffering > functions? They seem to implement what you're trying to do... > > http://www.php.net/manual/en/ref.outcontrol.php > > HTH, > > Richy > > -----Original Message----- > From: Paul H. Breslin [SMTP:phb@Canadian-Artist.com] > Sent: 21 December 2001 07:40 > To: php-general@lists.php.net > Subject: [PHP] Standard output (printf) question... > > I'm trying to create a function that will generate output that could go to > either a file or to the current browser directly. To do this I have > something > like: > > function GenerateOutput($out) > { > fwrite($out, "Some stuff"); > fflush($out); > } > > and to call it I tried: > > $stdout = fopen("php://stdout", "w"); > GenerateOutput($stdout); > > But for some reason nothing shows in the browser when I do this. > > I can't seem to find information about what output stream "printf" is > actually > writing to. Do we have access to this stream? > > Can anyone provide a hint as to why the above doesn't work? > > Thanks. _________________________________________________________________________ Paul H. Breslin http://Canadian-Artist.com mailto:phb@Canadian-Artist.com

« previous php.general (#78433) next »