note 97197 rejected from function.imagegif by danbrown
| From: | danbrown@php.net | Date: | Thu, 08 Apr 2010 13:34:47 +0000 |
| Subject: | note 97197 rejected from function.imagegif by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-168024@lists.php.net to get a copy of this message | ||
Note Submitter: Kris dot Craig at gmail dot com
----
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.