Bug #11226 Updated: Unable to reference functions inside a class via "Variable Funcitons"
| From: | mikehatesspam at bigfoot dot com | Date: | Mon, 18 Jun 2001 15:00:18 +0000 |
| Subject: | Bug #11226 Updated: Unable to reference functions inside a class via "Variable Funcitons" | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-56826@lists.php.net to get a copy of this message | ||
ID: 11226
User Update by: mikehatesspam@bigfoot.com
Old-Status: Feedback
Status: Open
Bug Type: Scripting Engine problem
Operating system: Linux 2.4.2 (Redhat Linux 7.1)
PHP Version: 4.0.4pl1
Description: Unable to reference functions inside a class via "Variable Funcitons"
I modified the code like this:
<?
function xyz() {
echo "This always works";
}
class test {
function testfunc() {
echo "This now works";
}
function calltest() {
$function_name = 'test::testfunc';
$function_name();
}
}
$t = new test;
$t->calltest();
?>
I got the exact same error. I just don't think it can find functions inside a class.
Previous Comments:
---------------------------------------------------------------------------
[2001-06-18 10:16:18] kalowsky@php.net
i do believe you need to declare the function testfunc() BEFORE you try to reference it. try that
and see if it works.
---------------------------------------------------------------------------
[2001-05-31 18:32:36] mikehatesspam@bigfoot.com
When I run this script I get this error message:
Fatal error: Call to undefined function: test::testfunc() in
/var/www/html/database/classes/Authenticator/test.php on line 9
I can execute the function by using test::testfunc();
directly, but not by using "Variable Functions". I can also
change $function_name to be 'xyz' and it then works.
<?
class test {
function calltest() {
$function_name = 'test::testfunc';
$function_name();
}
function testfunc() {
echo "This now worksn";
}
}
function xyz() {
echo "This always worksn";
}
$t = new test;
$t->calltest();
?>
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=11226