Re: Object method as handler functions in PHP4/Zend
| From: | Chuck Hagenbuch | Date: | Wed, 30 Jun 1999 04:49:29 +0000 |
| Subject: | Re: Object method as handler functions in PHP4/Zend | ||
| References: | 1 2 3 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-7857@lists.php.net to get a copy of this message | ||
Quoting Zeev Suraski <zeev@zend.com>:
> No, it doesn't mean that (I was talking about methods that don't really
> have object contexts). Frankly, I'm not really sure what you're after.
> You can pass that function a 'pointer' to an object, and a method name, and
> call $object->$method(). I think you could do that in PHP 3.0, but if you
> couldn't, you can do it using PHP 4.0.
I may have an example that will illustrate the point in question:
class foo {
function mysort ($a, $b) {
// blah
}
function dostuff ($stuffarray) {
$sorted = usort($stuffarray, '$this->mysort');
}
}
I couldn't find anything that would work as the second argument to usort; I
had to make mysort() a global routine. I take it in php4, you'll at least be
able to put 'foo::mysort' as the second argument. However, if mysort()
references class variables (ie, it's not a static method - in the java
sense, at least), will there be a way to use a reference to a specific
object's mysort function?
Manuel, is this what you were referring to?
-chuck
--
Charles Hagenbuch, <chagenbu@wso.williams.edu>
--
"whatever is wrong with you ... it is no small thing." - dan