Re: Class methods for custom functions
| From: | Andrei Zmievski | Date: | Tue, 04 Dec 2001 14:23:38 +0000 |
| Subject: | Re: Class methods for custom functions | ||
| References: | 1 2 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-2118@lists.php.net to get a copy of this message | ||
On Tue, 04 Dec 2001, Anders Janson wrote:
> To me, a class method is "theclass::thefunction()". It could be called
> without having an object instance.
> Wouldn't it be possible to just register "myclass::funcname" as the name of
> a custom function? I can't test this right now, so it's just a guess...
No, you can't. The proper way to do it would be to register
array('theclass', 'thefunction') (called closure).
> Well, if it works it only means we can use the namespace encapsulation that
> classes provide, but that's not too bad ;-)
>
> Here I get the impression that you were talking about registering
> $theobject->thefunction(). This is certainly a method in a class, but IMHO
> it is not a class method. At least that's what my C++/OOP teachers told me
> :-)
Umm, what is it then? An object instance method? Anyway, what I meant is
registering either static methods or instance-based ones. They would all
work, but it may result in a slight slowdown. Of course if you use
cache, it is obviated.
-Andrei
The Heineken Uncertainty Principle:
You can never be sure how many beers you had last night.