Re: R: [PHP] Interface problem...
| From: | Teodor Cimpoesu | Date: | Mon, 25 Sep 2000 07:35:53 +0000 |
| Subject: | Re: R: [PHP] Interface problem... | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-17416@lists.php.net to get a copy of this message | ||
Hi Andrioli!
On Wed, 20 Sep 2000, Andrioli Darvin wrote:
>
> > I am going to create a system (in php) of loadable modules similar to
> > Win32/COM. I am working on interface system and I want to use a "Variable
> > functions" feature for it. Unfortunately it doesn't work for class
> methods.
> > Here is a code:
> >
> > <?php
> > class Test {
> > var $varFunc = "func1";
> >
> > function func1() {
> > echo "exec: func1";
> > }
> > }
> >
> > $t = new Test;
> >
> > $t->varFunc();
> > ?>
> >
>
> The following statement should work with your example.
>
> eval("\$t->" . $t->varFunc ."();");
try to avoid eval() when possible...
better use $t->{$t->varFunc}();
it will work nicely.
-- teodor