#32690 [Bgs]: Using function_exists() doesn't always work.
| From: | gregt at maths dot otago dot ac dot nz | Date: | Wed, 13 Apr 2005 23:54:50 +0000 |
| Subject: | #32690 [Bgs]: Using function_exists() doesn't always work. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-77509@lists.php.net to get a copy of this message | ||
ID: 32690
User updated by: gregt at maths dot otago dot ac dot nz
Reported By: gregt at maths dot otago dot ac dot nz
Status: Bogus
Bug Type: GD related
Operating System: Linux
PHP Version: 4.2.3
New Comment:
Then it must be an upstream packaging error. I downloaded, compiled
and installed a tarball for php-4.3.9
Apologies for "wasting your time", but I had been led to believe I was
running the version I had stated.
Previous Comments:
------------------------------------------------------------------------
[2005-04-13 23:23:32] derick@php.net
This was fixed loooong ago - do not lie about version numbers, you just
wasted 15 minutes of my time.
------------------------------------------------------------------------
[2005-04-13 09:16:46] derick@php.net
Tony, you're wrong - if something doesn't work it should not be
available. Assigning to you :)
------------------------------------------------------------------------
[2005-04-13 08:25:06] tony2001@php.net
This is expected behaviour.
Use gd_info() to get the version of GD library you have.
------------------------------------------------------------------------
[2005-04-13 06:32:56] gregt at maths dot otago dot ac dot nz
Description:
------------
When using function function_exists() to test for presence of a
function, the result is sometimes wrong.
Consider the following:
echo "a:", function_exists(imagecreate),"<br>";
echo "b:", function_exists(imagecreatetruecolor),"<br>";
echo "c:", function_exists(imagecreatetruecolorrrr),"<br>";
echo phpinfo(8);
This produces the output:
a: 1
b: 1
c:
<snip>
gd
GD Support enabled
GD Version 1.6.2 or higher
FreeType Support enabled
FreeType Linkage with freetype
JPG Support enabled
PNG Support enabled
WBMP Support enabled
When I call imagecreatetruecolor(), I get:
Warning: imagecreatetruecolor(): requires GD 2.0 or later in
/home/gregt/public_html/gd/gdtest.php on line 8
Obviously I don't have a proper implementation of the
imagecreatetruecolor function, but there is still code there to throw
an error, so function_exists blindly assumes the function is present.
Reproduce code:
---------------
<?
echo "a:", function_exists(imagecreate),"<br>";
echo "b:", function_exists(imagecreatetruecolor),"<br>";
echo "c:", function_exists(imagecreatetruecolorrrr),"<br>";
echo phpinfo(8);
?>
Expected result:
----------------
a: 1
b:
c:
Actual result:
--------------
a: 1
b: 1
c:
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=32690&edit=1