note 101082 added to function.ob-start

From: Date: Thu, 25 Nov 2010 00:35:51 +0000
Subject: note 101082 added to function.ob-start
Groups: php.notes 
Request: Send a blank email to php-notes+get-174340@lists.php.net to get a copy of this message
Careful with while using functions that change headers of a page; that change will not be undone when ending output buffering. If you for instance have a class that generates an image and sets the appropriate headers, they will still be in place after the end of ob. For instance: <?php ob_start(); myClass::renderPng(); //header("Content-Type: image/png"); in here $pngString = ob_get_contents(); ob_end_clean(); ?> will put the image bytes into $pngString, and set the content type to image/png. Though the image will not be sent to the client, the png header is still in place; if you do html output here, the browser will most likely display "image error, cannot be viewed", at least firefox does. You need to set the correct image type (text/html) manually in this case. ---- Server IP: 69.147.83.197 Probable Submitter: 108.21.7.186 ---- Manual Page -- http://www.php.net/manual/en/function.ob-start.php Edit -- https://master.php.net/note/edit/101082 Del: integrated -- https://master.php.net/note/delete/101082/integrated Del: useless -- https://master.php.net/note/delete/101082/useless Del: bad code -- https://master.php.net/note/delete/101082/bad+code Del: spam -- https://master.php.net/note/delete/101082/spam Del: non-english -- https://master.php.net/note/delete/101082/non-english Del: in docs -- https://master.php.net/note/delete/101082/in+docs Del: other reasons-- https://master.php.net/note/delete/101082 Reject -- https://master.php.net/note/reject/101082 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#174340) next »