note 81196 added to function.headers-sent

From: Date: Mon, 18 Feb 2008 06:54:54 +0000
Subject: note 81196 added to function.headers-sent
Groups: php.notes 
Request: Send a blank email to php-notes+get-136237@lists.php.net to get a copy of this message
very handy function! When working with GD I made something like: <?php class image{ /** * show * sends image to browser and destroy the resource if headers not sent. * use php constants IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG * * @final * @static * @access public * @param resource $resource * @param int $type */ final static public function show($resource, $type){ if(!headers_sent()){ header('Cache-control: private'); switch($type){ case IMAGETYPE_GIF : header('Content-type: image/gif'); header('Content-Disposition: filename='.basename(__FILE__).'.gif'); imagegif($resource); break; case IMAGETYPE_JPEG : header('Content-type: image/jpeg'); header('Content-Disposition: filename='.basename(__FILE__).'.jpg'); imagejpeg($resource, NULL, 99); break; case IMAGETYPE_PNG : header('Content-type: image/png'); header('Content-Disposition: filename='.basename(__FILE__).'.png'); imagepng($resource, NULL, 0, NULL); break; } imagedestroy($resource); exit; } } } ?> This way if you are debugging... and flush output... you will not get the endless list of headers allready send errors... Hope it's helpfull... ;) ---- Server IP: 89.248.170.58 Probable Submitter: 62.234.63.246 ---- Manual Page -- http://www.php.net/manual/en/function.headers-sent.php Edit -- https://master.php.net/note/edit/81196 Del: integrated -- https://master.php.net/note/delete/81196/integrated Del: useless -- https://master.php.net/note/delete/81196/useless Del: bad code -- https://master.php.net/note/delete/81196/bad+code Del: spam -- https://master.php.net/note/delete/81196/spam Del: non-english -- https://master.php.net/note/delete/81196/non-english Del: in docs -- https://master.php.net/note/delete/81196/in+docs Del: other reasons-- https://master.php.net/note/delete/81196 Reject -- https://master.php.net/note/reject/81196 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#136237) next »