note 97214 added to function.imagegif

From: Date: Thu, 08 Apr 2010 14:07:05 +0000
Subject: note 97214 added to function.imagegif
Groups: php.notes 
Request: Send a blank email to php-notes+get-168027@lists.php.net to get a copy of this message
** THIS IS NOT A BUG REPORT! DO NOT DELETE IT! ** This is a suggestion for people who are using the function not to pass a NULL value for the $filename argument, with a detailed explanation as to why as well as a suggested alternative. 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/97214 Del: integrated -- https://master.php.net/note/delete/97214/integrated Del: useless -- https://master.php.net/note/delete/97214/useless Del: bad code -- https://master.php.net/note/delete/97214/bad+code Del: spam -- https://master.php.net/note/delete/97214/spam Del: non-english -- https://master.php.net/note/delete/97214/non-english Del: in docs -- https://master.php.net/note/delete/97214/in+docs Del: other reasons-- https://master.php.net/note/delete/97214 Reject -- https://master.php.net/note/reject/97214 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#168027) next »