Quick question on abstract methods

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
VirtuosiMedia
Forum Contributor
Posts: 133
Joined: Thu Jun 12, 2008 6:16 pm

Quick question on abstract methods

Post by VirtuosiMedia »

Can the child classes change, add, or subtract parameters for abstract methods or must all parameters be defined in the abstract method? I didn't see a quick answer about parameter rules for abstract methods in any of the articles I looked at or in the PHP documentation.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Quick question on abstract methods

Post by alex.barylski »

The best answer is to just try it and find out.

If you must read about it officially then Google PHP method overriding *not* overloading -- the latter of which I am pretty sure PHP doesn't support.
WebbieDave
Forum Contributor
Posts: 213
Joined: Sun Jul 15, 2007 7:07 am

Re: Quick question on abstract methods

Post by WebbieDave »

VirtuosiMedia wrote:Can the child classes change, add, or subtract parameters for abstract methods
No, the signatures must match.
Hockey wrote:If you must read about it officially then Google PHP method overriding *not* overloading -- the latter of which I am pretty sure PHP doesn't support.
Though they don't possess the ease of use as compared to other OOP languages, there are definitely means within PHP to facilitate method/property overloading.
http://us.php.net/manual/en/overload.examples.php
User avatar
VirtuosiMedia
Forum Contributor
Posts: 133
Joined: Thu Jun 12, 2008 6:16 pm

Re: Quick question on abstract methods

Post by VirtuosiMedia »

WebbieDave wrote: No, the signatures must match.
Thanks.
Post Reply