variable functions as class members
| From: | Phil Glatz | Date: | Wed, 14 Jun 2000 07:48:13 +0000 |
| Subject: | variable functions as class members | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-21289@lists.php.net to get a copy of this message | ||
I have a global function called 'globe'
Within a class, I have a member function called 'foo'
Another member function, 'test', has a variable function call within it, with the name of the function to call as a string argument to it.
I can refer to the global function 'globe' as an argument to it, and it will execute. But what I'd really like to do would be able to call test() from another function within the class, and use the 'foo' member function of the same class as its argument.
Is this possible? What would the syntax be?
# member function
function test($arg) {
$arg();} # member function function foo() {
# does something...} this works: $this->test('globe'); but how could I refer to $test->foo() as an argument to test? this won't work: $this->test('this->foo'); any kind of syntactical hack to do this? I'm using php4