Re: Function variables in classes
| From: | Sebastian Hopfe | Date: | Thu, 01 Nov 2007 12:16:58 +0000 |
| Subject: | Re: Function variables in classes | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-263911@lists.php.net to get a copy of this message | ||
It seems to be a PHP Bug, because normaly it should very well.
but you can solve this problem, by a workarround.
using "eval($a."();");" instead of "$a();" in the class.
Best regards
Sebastian
"Paul van Haren" <paul.vanharen@zonnet.nl> schrieb im Newsbeitrag news:35.A3.03551.B24B9274@pb1.pair.com...
Hi there, I'm trying to execute function variables. This works fine outside class code, but gives a fatal error when run within a class. The demo code is here: <?php function bar1 () {echo "Yep, in bar1() right now\n";} function foo1 () {bar1();$a = "bar1"; print_r ($a); echo "\n"; $a();} class foobar {function bar2 () { echo "Yep, in bar2() right now\n"; }public function foo2 () { foobar::bar2();$a = "foobar::bar2"; print_r ($a); echo "\n"; $a(); }} foo1(); $fb = new foobar (); $fb->foo2(); ?> The error message reads: Fatal error: Call to undefined function foobar::bar2() in /home/paul/demo/demo.php on line 25 Is there anyone out there who can explain what's wrong in this code? Thanks, Paul