* Thus wrote Julio Sergio Santana:
>
> Curt Zirzow wrote:
>
> > $this->{$this->fname}();
> >
> > or (what it actually is doing.. )
> >
> > $func = $this->fname;
> > $this->$func();
> >
> >Curt
>
> The point here is that the named function is outside the object. That
> is, $this->foo() doesn't exist, so $this->{$this->fname}(), does not
> work either.
> But if you look at your suggested construct, I wonder why
> $this->{$this->fname}() is sintactically correct while
> {$this->fname}() is not (since we just striped out the prefix '$this->'
> which means that the function is inside the object).
Sorry, i did misread what actual function you were trying to
access, the problem is that {} isn't really the thing that expands
the variable its the special cases:
->{}
${}
{} by itself simply defines a code block.
> ...
>
> Clearly, $this->fname() means "call the object's method 'fname'", but
> {$this->fname}(), would mean "call the function whose name is
> '$this->fname'".
> I think, for the sake of orthogonallity, this feature should be added to
> the language.
One way to solve this without adding a feature like that would be:
${$this->fname} = $this->fname;
${$this->fname}();
or for the oneline purists :)
${ ${$this->fname} = $this->fname }();
wow.. ${} is more powerful than i had originally though.
Curt
--
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about. No, sir. Our model is the trapezoid!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php