Re: Reliable header sending mechanism in php 6

From: Date: Wed, 28 Nov 2007 00:00:02 +0000
Subject: Re: Reliable header sending mechanism in php 6
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-33480@lists.php.net to get a copy of this message
On Nov 28, 2007 12:38 AM, Ezra Nugroho <enugroho@spikesource.com> wrote: > > On Tue, 2007-11-27 at 14:50 +1000, Rasmus Lerdorf wrote: > > Ezra Nugroho wrote: > > > Can I ask for the following support, at least to begin conversation > > > about it if it hasn't been done before. > > > > > > Currently, the header() function still carries the following warning in > > > its online documentation: > > > > > > "Remember that header() must be called before any actual output is sent, > > > either by normal HTML tags, blank lines in a file, or from PHP. It is a > > > very common error to read code with include(), or require(), functions, > > > or another file access function, and have spaces or empty lines that are > > > output before header() is called. The same problem exists when using a > > > single PHP/HTML file." > > > > > > This is quite annoying since this makes header() or setcookie() calls to > > > be unreliable. > > > > > > I am aware that it can be done more reliably by turning the output > > > buffering on. This is less of an issue if you are writing your own > > > webapp. However, this is much more difficult if a person writes a > > > library for other people's consumptions. The library cannot enforce > > > output buffering in the webapp. > > > > > > Can we please give it a thought in PHP 6? Maybe by turning output > > > buffering on by default, or even by enforcing output buffering. > > > > > > In Java, you can get the request object, and the response object of a > > > web request. I find this very useful and reliable. > > > > > > Any thoughts or comments about this? > > > > There is nothing unreliable about is as far as I am concerned. You have > > full control over output buffering from your script. Forcing people to > > buffer output by default will mean higher memory usage and higher > > latency for existing scripts with no gain given their code is working today. > > > In my mind, it is still unreliable... > When I write my library, how can I enforce people who adopt it to enable > ob? > > Furthermore, I think it's quite annoying that some functions may not > work just because of an inclusion of a blank space somewhere in a file > that you don't maintain. > > As php applications get bigger, and developers have only a small scope > of the big picture, the reliability of the functions becomes bigger and > bigger deal. http://docs.php.net/manual/en/outcontrol.configuration.php -Hannes

« previous php.internals (#33480) next »