Re: Variable functions within an object
| From: | Julio Sergio Santana | Date: | Fri, 30 Jul 2004 18:02:42 +0000 |
| Subject: | Re: Variable functions within an object | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-192332@lists.php.net to get a copy of this message | ||
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: <?php function foo() { echo "In foo()<br />\n"; } class a { var $fname; function a() {
$this->fname = 'foo'; // the name of the function} function execute() { // method to execute the named function
${${$this->fname}=$this->fname}();
}
}
$w = new a;
$w->execute();
?>
And this outputs:
X-Powered-By: PHP/4.1.2
Content-type: text/html
In foo()<br />
Thank you again,
Sergio.