Re: Redirecting PHP output in script

From: Date: Mon, 05 Jul 1999 23:45:54 +0000
Subject: Re: Redirecting PHP output in script
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-8108@lists.php.net to get a copy of this message
Hello Sean, On 05-Jul-99 15:26:15, you wrote: >I have developed a tool for generating web sites from a database, and >I'm working on improving the scripting language. It makes sense to >choose something familiar, simple and in use for server side scripting. >PHP is ideal. >Essentially the program would run a script to traverse the database and >generate output page-by-page using templates, each template is >effectively a separate PHP script. >The fact that all output goes to stdout is a bit of a problem. I need >to be able to direct the output of a template to a specific file. >No big deal really, I have done this using a drop-in module that >redirects stdout, but this is far from perfect. Also I would like to >allow output to take place through user supplied functions. I have already suggested this as improvement of PHP output control, but I'm afraid nobody in the core development team cared about the suggestion. Instead, it seems that PHP 4 will have some sort of output buffering control. This is not quite the same because everything will be buffered, including error messages (asking for more puzzling "Document contains no data" errors) and you have to flush the buffer explicitly. I suggested that the user could define a function that would be called to let it divert the output to wherever is needed, but it seems that this was not considered to be a good idea. >The way to achieve this is to rewrite the php3_??? output functions to >use a global FILE that is manipulated through a new core module >implementing functions such as: > openoutput(path, mode) > closeoutput() > flushoutput() > registeroutput(func) >These would maintain a push-down stack of file details so that when >closeoutput() is called output reverts to the previous stream. >At present this will only work for the CGI version - fine. The rewrite >seems simple if non-trivial. Is this work likely to be of interest or >am I on my own in having a use for it? Should I submit any changes I >make? How do I do that? Sorry if the latter is a FAQ, I'm doing this >on the spur of the moment. I am interested in the idea because I have developed a server side page caching engine but it is hard to make it nest. Even with PHP4 global buffering it won't be any easier. Your solution addresses the nesting ability problem. As for submiting your changes, you may try, but I'm afraid they might not be accepted for integration in PHP (I hope I am wrong). It seems the core PHP development team doesn't like anybody else to mess with PHP core functions. I don't know even if your improvements may fit as optional module in PHP 4 as it changes the behaviour of PHP core functions. Just try to submit it any way. Regards, Manuel Lemos Web Programming Components using PHP Classes. Look at: http://phpclasses.UpperDesign.com/?user=mlemos@acm.org -- E-mail: mlemos@acm.org URL: http://www.mlemos.e-na.net/ PGP key: finger://mlemos@zeus.ci.ua.pt --

« previous php.dev (#8108) next »