php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #35061 imagegif,png,ipg.second parameter can not be set ''(null)
Submitted: 2005-11-02 06:39 UTC Modified: 2005-11-02 09:44 UTC
From: surfchen at gmail dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 4.4.0 OS: Redhat AS
Private report: No CVE-ID: None
 [2005-11-02 06:39 UTC] surfchen at gmail dot com
Description:
------------
1)the imagegif,imagejpg,imagepng can not be used with tow parameters which the 2nd parameter is ''(null).but if give the function more than 2 parameters,it works.
2)imagegif can give 4 parameters while the document just says it just have tow parameters.



Reproduce code:
---------------
<?php//incorrect.1)
$img=imagecreatefromgif('2.gif');
header("Content-type:image/gif");
imagegif($img,'');
?>
<?php//correct(with 4 parameters).2)
$img=imagecreatefromgif('2.gif');
header("Content-type:image/gif");
imagegif($img,'',55,22);
?>

Expected result:
----------------
1) should ouput correct.
2) should ouput a error because that it have 4 parameters

Actual result:
--------------
1)output a incorrect image
2)ouput correctly

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-11-02 09:01 UTC] derick@php.net
Marking as a doc problem then.
 [2005-11-02 09:16 UTC] surfchen at gmail dot com
maybe it's not just a documentation problem.
 [2005-11-02 09:17 UTC] vrana@php.net
Third and fourth parameter of this function is silently ignored. Empty string for the second parametr can be used to skip it but if a function has only two parameters, there's nothing to skip and the second parameter is used. If you just want to output the image, simply call imagegif($img).
 [2005-11-02 09:27 UTC] surfchen at gmail dot com
1)
I must write more code when I can't sure a filename(2nd parameter) will be a empty string or a normal string.
if ($filename=='')
{
   imagegif($img);
}
else
{
   imagegif($img,$filename);
}
2)why the imagegif have 4 parameters while imagepng,imagejpg have 3?
 [2005-11-02 09:44 UTC] vrana@php.net
Yes, you have to write more code.

All functions internally call the same function. imagegd2() has 4 parameters so this internal function accepts mostly 4 parameters. In other functions, they are ignored.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 16:01:36 2025 UTC