php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32690 Using function_exists() doesn't always work.
Submitted: 2005-04-13 06:32 UTC Modified: 2005-04-14 01:54 UTC
From: gregt at maths dot otago dot ac dot nz Assigned:
Status: Not a bug Package: GD related
PHP Version: 4.2.3 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: gregt at maths dot otago dot ac dot nz
New email:
PHP Version: OS:

 

 [2005-04-13 06:32 UTC] 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:



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-04-13 08:25 UTC] tony2001@php.net
This is expected behaviour.
Use gd_info() to get the version of GD library you have.
 [2005-04-13 09:16 UTC] derick@php.net
Tony, you're wrong - if something doesn't work it should not be available. Assigning to you :)
 [2005-04-13 23:23 UTC] derick@php.net
This was fixed loooong ago - do not lie about version numbers, you just wasted 15 minutes of my time.
 [2005-04-14 01:54 UTC] gregt at maths dot otago dot ac dot nz
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.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 10:01:38 2025 UTC