Oli Filth wrote:
MrKrinkle said the following on 09/06/2005 20:38: I want to universally define the __call() method, so that every class
in my application does the same thing if a non-existant function is
called.
In actionscript I could do this by adding the definition to the
prototype for Object.
Is there any way to do that in php 5? I could make every one of my
classes inherit from like an Object class that I define, but that kind
of sucks.
Hang on, you want to have a load of classes inherit a particular
behaviour, but you don't want to specify that they extend a base class
that defines this behaviour?? Why?
--
Oli
Well, a couple reasons:
A. I want EVERY object in the application to have this behavior.
B. If I've already defined classes (and I have) then I would have to go
back and add "extends MyBaseObject" to all of the root classes. Some
of the classes come from other people, so each time they send me an
update of their source, I'd have to modify it, or get them to do this
for me anyway.
C. Since I'm redefining/overriding the __call function, which is
already on whatever "base" class php has for objects (what would be
"Object" in java), then it makes sense to modify the prototype rather
than invent my own Object class.
In AS 2 this would be easy.
In my experience, asking someone "but why would you want to do that" is
never fruitful, it's usually a way to avoid trying to answer the
question.