#42473 [Opn->Csd]: ob_start php://output and headers

From: Date: Wed, 26 Nov 2008 01:21:20 +0000
Subject: #42473 [Opn->Csd]: ob_start php://output and headers
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-131330@lists.php.net to get a copy of this message
ID: 42473 Updated by: lbarnaud@php.net Reported By: ce at netage dot bg -Status: Open +Status: Closed Bug Type: Apache2 related Operating System: * PHP Version: 5.2.6 New Comment: This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2008-06-05 17:25:06] biggi at stefna dot is I am getting this error as well. Using php-5.2.6 and Apache 2.0 handler. I do not think the php://output stream should be affected by fclose since the stream really is not affected by fopen. For information (example of a workaround): http://framework.zend.com/issues/browse/ZF-3396 ------------------------------------------------------------------------ [2007-09-23 09:32:12] tzachi at zend dot com The problem seems to be with fclose($fp) when $fp=php://output. fclose flushes headers and output in Apache handler(and filter, also it seems that in other SAPIs this situation will not occur), so headers are sent at this point. You can use this in order to partially fix: <?php ob_start(); $fp = fopen('php://output', 'w'); fwrite($fp, 'aaaaaaa'); $content = ob_get_clean(); header('Content-type: text/html'); echo $content; fclose($fp); ------------------------------------------------------------------------ [2007-09-10 12:58:10] kouber@php.net The bug is still present under Windows XP, PHP 5.2.4. I'm using php.ini-recommended with display_errors = On. ------------------------------------------------------------------------ [2007-08-30 13:54:56] ce at netage dot bg with windows and apache and again Server API -> Apache 2.0 Handler it is reproducable, so I suppose the problem is something connected to the server api here the CGI version in action - no problem ce@ce:/usr/local/php-5.2.4/bin$ ./php-cgi <?php error_reporting(E_ALL); ob_start(); $fp = fopen('php://output', 'w'); fwrite($fp, 'aaaaaaa'); fclose($fp); $content = ob_get_clean(); header('X-z: 1'); echo $content; X-Powered-By: PHP/5.2.4RC3 X-z: 1 Content-type: text/html aaaaaaace@ce:/usr/local/php-5.2.4/bin$ ------------------------------------------------------------------------ [2007-08-30 13:39:19] ce at netage dot bg I just compile the latest version 5.2.4RC3 ./configure --with-apxs2=/usr/bin/apxs2 --prefix=/usr/local/php-5.2.4 no php.ini, so everything is default but I have discovered that if using CGI server api it is not reproducable this is from phpinfo() I can give some other info for my configuration if needed Build Date Aug 30 2007 15:09:33 Configure Command './configure' '--with-apxs2=/usr/bin/apxs2' '--prefix=/usr/local/php-5.2.4' Server API Apache 2.0 Handler Virtual Directory Support disabled Configuration File (php.ini) Path /usr/local/php-5.2.4/lib Loaded Configuration File (none) PHP API 20041225 PHP Extension 20060613 Zend Extension 220060519 Debug Build no ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/42473 -- Edit this bug report at http://bugs.php.net/?id=42473&edit=1

« previous php.bugs (#131330) next »