note 24931 added to functions.variable-functions
| From: | madeinlisboa at yahoo dot com | Date: | Thu, 05 Sep 2002 10:14:05 +0000 |
| Subject: | note 24931 added to functions.variable-functions | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-36154@lists.php.net to get a copy of this message | ||
Finally, a very easy way to call a variable method in a class:
Example of a class:
class Print() {
var $mPrintFunction;
function Print($where_to) {
$this->mPrintFunction = "PrintTo$where_to";
}
function PrintToScreen($content) {
echo $content;
}
function PrintToFile($content) {
fputs ($file, $contents);
}
.. .. ..
// first, function name is parsed, then function is called
$this->{$this->mPrintFunction}("something to print");
}
--
http://www.php.net/manual/en/functions.variable-functions.php
http://master.php.net/manage/user-notes.php?action=edit+24931
http://master.php.net/manage/user-notes.php?action=delete+24931
http://master.php.net/manage/user-notes.php?action=reject+24931