Curt Zirzow wrote:
or for the oneline purists :)
${ ${$this->fname} = $this->fname }();
wow.. ${} is more powerful than i had originally though.
Thank you Curt,
With your suggestion, I finally re-wrote the example, and here it is:
function foo() {
echo "In foo()\n";
}
class a {
var $fname;
* 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
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
http://ca3.php.net/manual/en/function.call-user-func.php ?
Jason
On Thu, 29 Jul 2004 17:11:50 -0500, Julio Sergio Santana
<[EMAIL PROTECTED]> wrote:
> I need to record the names of functions, and then use them later.
> Recently I found the following example within the on-line documentation:
>
* Thus wrote Julio Sergio Santana:
>
> class a {
> var $fname;
> function a() {
> $this->fname = 'foo'; // the name of the function
> }
>
> function execute() { // method to execute the named function
> $this->fname();
> // I also tried here
> // {$this->fname}();
> //
I need to record the names of functions, and then use them later.
Recently I found the following example within the on-line documentation:
\n";
}
$func = 'foo';
$func();// This calls foo()
?>
then I supposed that it was easy to extend this concept to objects and
wrote the following case:
6 matches
Mail list logo