Re: Function variables in classes
| From: | Nathan Nobbe | Date: | Fri, 02 Nov 2007 14:16:12 +0000 |
| Subject: | Re: Function variables in classes | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-263968@lists.php.net to get a copy of this message | ||
On 11/2/07, rohini <deepthirohini@gmail.com> wrote:
>
>
> Hi paul,
> Why you are trying to use the scope resolution operator see you can use
> this way simply.
>
> Code:
> ******
> <?php
> class foobar {
> function bar2 () {
> echo "Yep, in bar2() right now\n";
> }
>
> public function foo2 () {
> $a = "bar2"; // Experiment 0
> $a(); // Fatal error
> }
> }
> $foo = new foobar();
> $funname = "bar2";
> $foo->$funname();
> ?>
>
perhaps hes not working with an instance of the class.
it is perfectly reasonable to use the scope resolution operator in a
variable function.
you just cant include the scope resolution operator in the string that gets
handed to
the interpreter. take a look at the code fragments from yesterday for
examples.
-nathan