|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2001-05-31 18:32 UTC] mikehatesspam at bigfoot dot 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 works\n";
}
}
function xyz() {
echo "This always works\n";
}
$t = new test;
$t->calltest();
?>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 09:00:01 2025 UTC |
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.