note 97197 added to function.imagegif

From: Date: Thu, 08 Apr 2010 06:58:41 +0000
Subject: note 97197 added to function.imagegif
Groups: php.notes 
Request: Send a blank email to php-notes+get-167999@lists.php.net to get a copy of this message
It should be noted that, contrary to what the manual implies, an error will be returned if you specify a NULL filename instead of simply omitting it. For example: function Test( $img, $filename = NULL ) { $ok = imagegif( $img, $filename ); } This will return an image that contains errors. However, if you simply omit $filename altogether, you'll be just fine. To make the above function work error-free, do this: function Test( $img, $filename = NULL ) { if ( $filename == NULL ) { $ok = imagegif( $img ); } else { $ok = imagegif( $img, $filename ); } } The manual somewhat inaccurately states the following for the $filename argument: "If not set or NULL, the raw image stream will be outputted directly." In fact, as I just demonstrated, this is misleading as it fails to mention that passing it as a NULL value causes a broken (error) image to be displayed. I would recommend you avoid this by simply making sure that you don't pass a NULL value for $filename. ---- Server IP: 69.147.83.197 Probable Submitter: 67.183.129.249 ---- Manual Page -- http://www.php.net/manual/en/function.imagegif.php Edit -- https://master.php.net/note/edit/97197 Del: integrated -- https://master.php.net/note/delete/97197/integrated Del: useless -- https://master.php.net/note/delete/97197/useless Del: bad code -- https://master.php.net/note/delete/97197/bad+code Del: spam -- https://master.php.net/note/delete/97197/spam Del: non-english -- https://master.php.net/note/delete/97197/non-english Del: in docs -- https://master.php.net/note/delete/97197/in+docs Del: other reasons-- https://master.php.net/note/delete/97197 Reject -- https://master.php.net/note/reject/97197 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#167999) next »