Justin Patrin wrote:

Chris wrote:

I have an abstract class with quite a few 'children'. Essentially I want to be able to interchange calls between children (Take a script, written with ClassA and redefine the variable as ClassB etc.)

Though there is a large subset of methods all of these children declare, there are a few which only *some* declare. What I think I'm looking for is a variation on an abstract method that, if not defined in a child, will do nothing. Using an abstract method forces me to declare the method in the child with an empty body.


AFAIK, there is no support for this explicitly in PHP5. You would have to implement something yourself, like putting a die() or exit in the abstract method in the parent class.


If you just want an empty funciton anyway, why don't you just put an empty function in the parent? I don't see why you would need PHP to yell at you when you don't want to do antyhing with it anyway.

When I said "will do nothing" I was meaning the method call, not the entire script. I can't put anything into an abstract method, it only defines the method name and argument list, a body is nto allowed in an abstract method.

Upon further reflection it appears that the abstract method is what I really want. I'll just have to implement an empty body.

Thanks

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to