#32690 [NEW]: Using function_exists() doesn't always work.
| From: | gregt at maths dot otago dot ac dot nz | Date: | Wed, 13 Apr 2005 04:32:57 +0000 |
| Subject: | #32690 [NEW]: Using function_exists() doesn't always work. | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-77443@lists.php.net to get a copy of this message | ||
From: gregt at maths dot otago dot ac dot nz
Operating system: Linux
PHP version: 4.3.9
PHP Bug Type: GD related
Bug description: Using function_exists() doesn't always work.
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 bug report at http://bugs.php.net/?id=32690&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=32690&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=32690&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=32690&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=32690&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=32690&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=32690&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=32690&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=32690&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=32690&r=support
Expected behavior: http://bugs.php.net/fix.php?id=32690&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=32690&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=32690&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=32690&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=32690&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=32690&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=32690&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=32690&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=32690&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=32690&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=32690&r=mysqlcfg