Re: Spurious newlines when requesting empty php file

From: Date: Fri, 10 Dec 2004 21:39:58 +0000
Subject: Re: Spurious newlines when requesting empty php file
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-203978@lists.php.net to get a copy of this message
Carl Michael Skog wrote: > Some strange results with spurious newlines inserted in the response when > requesting a php file has led me to investigating what happens when a > completely empty php-file is requested. > > I would have thought that the response from a empty php file would also be > empty, but, to my surprise, they consist of 3 newlines !!! > > The strange thing is that I observed this behaviour on two completely > unrelated servers. > > Is this what can be expected or is it a result of misconfiguration ? I just tried this with an empty PHP file, and got exactly what I expected. A valid response with no content at all. Please specify your software versions, and provide URLs and, as silly as this sounds, an "ls -als empty.php" so we can see your empty PHP file. Also check php.ini for auto_prepend_file and auto_append_file settings, which might be tacking on blanks. And, if you are using this as an "empty" file: --------------- not quite empty file ----------------- <?php ?> ------------------------------------------------------ then PHP is quite right to send out the newline at the end. ----------------- really empty file ----------------- <?php ?>----------------------------------------------------- Note that some editors, under some configurations, will *ADD* a newline to a file on the last line for historical reasons. Re-configure your editor *now* if yours does that, our include files and calls to http://php.net/header will drive you crazy, or you'll end up mis-using output buffering to "solve" your non-problem. -- Like Music? http://l-i-e.com/artists.htm

« previous php.general (#203978) next »