|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-04-29 00:46 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Sun Feb 15 08:00:01 2026 UTC |
try using "callable": <?php class A { function foo() { } } echo "A::foo is_callable? ". is_callable(Array('A', 'foo')) ."\n"; ?> Outputs: A::foo is_callable? 1 So basically, this request should be re-bogusified...