#28211 [Opn->Bgs]: function_exists() returns false on static functions
| From: | iliaa@php.net | Date: | Thu, 29 Apr 2004 13:22:27 +0000 |
| Subject: | #28211 [Opn->Bgs]: function_exists() returns false on static functions | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-58993@lists.php.net to get a copy of this message | ||
ID: 28211
Updated by: iliaa@php.net
Reported By: gk at proliberty dot com
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: linux red hat 9
PHP Version: 4.3.4
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
You need to use method_exists() for object methods.
Previous Comments:
------------------------------------------------------------------------
[2004-04-29 00:46:07] gk at proliberty dot com
Description:
------------
function_exists() returns false on static functions
method_exists() won't work without an instance of object
many times i have a deep class hierarchy and subclasses need to call
inherited static methods. instances of each ancestor class in the
hierarchy do not generally exist so method_exists() doesn't solve the
problem.
If this is not a bug but a feature request, then it is also a
documentation bug since the manual does not mention that
function_exists() does not work with class member functions, which are
truly 'functions', not 'methods'. 'method' assumes a class instance.
[greg@p3 test]$ php -v
PHP 4.3.2-RC (cli) (built: Apr 25 2003 18:03:38)
Reproduce code:
---------------
<?php
class a {
function a(){
}
function static_func(){
echo ("a::static_func() - the static function really
exists!\n");
}
}
a::static_func();
$function_exists = function_exists("a::static_func") ? 'exists': 'does
not exist';
echo ("function_exists(\"a::static_func\") thinks that: \n");
echo("a::static_func() $function_exists\n");
$function_exists = function_exists("static_func") ? 'exists': 'does not
exist';
echo ("function_exists(\"static_func\") thinks that: \n");
echo("static_func() $function_exists\n");
?>
Expected result:
----------------
[greg@p3 test]$ php test.php
a::static_func() - the static function really exists!
function_exists("a::static_func") thinks that:
a::static_func() exists
function_exists("static_func") thinks that:
static_func() does not exist
Actual result:
--------------
[greg@p3 test]$ php test.php
a::static_func() - the static function really exists!
function_exists("a::static_func") thinks that:
a::static_func() does not exist
function_exists("static_func") thinks that:
static_func() does not exist
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=28211&edit=1