ronpac
asked on
Default output stream
How do I change the default output stream in PHP? I'm caching output to file and want to change the default output stream to a file. My script script will have a loop and I need to be able to change the output stream on the fly. For example....
The first iteration might be New York, so the stream needs to be NewYork.txt so all output will go to this file...the next file might be Chicago...so that file needs to be Chicago.txt. Thank you.
The first iteration might be New York, so the stream needs to be NewYork.txt so all output will go to this file...the next file might be Chicago...so that file needs to be Chicago.txt. Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Oh, I like peyox example so far....simple enough. I think that's the way to go, I guess if I'm writing to multiple files, I'll have to close them, didn't think about that.
Okay, I'll keep this open for a bit longer but I think you got it. The only thing that would be best (if possible) is to change the standard output on the file so that I wouldn't have to worry about the buffering, fputs, or fclose commands. Again, peyonx makes a lot of sense and very simple. I'll take a look at the Output Control functions. Thank you.
Okay, I'll keep this open for a bit longer but I think you got it. The only thing that would be best (if possible) is to change the standard output on the file so that I wouldn't have to worry about the buffering, fputs, or fclose commands. Again, peyonx makes a lot of sense and very simple. I'll take a look at the Output Control functions. Thank you.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Okay, I split the points.....I haven't implemented either of the solutions. I've requested these solutions to implement a caching system but at the moment it isn't needed....seems like a simple database index solved my index for now. Thanks for your help and I'll have this for future reference when I start the caching system again.
Smarty does a VERY good templating/caching system.
ASKER
Thanks RQuadling...I'll research Smarty for caching.
Either alter the script so no output is generated, but instead, a variable is written to and at the end of the script write it all out to the appropriate file. Or use output buffering.
Regards,
Richard Quadling.