Page 1 of 1

Quick question on abstract methods

Posted: Wed Jul 16, 2008 12:56 pm
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.

Re: Quick question on abstract methods

Posted: Wed Jul 16, 2008 1:02 pm
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.

Re: Quick question on abstract methods

Posted: Wed Jul 16, 2008 1:27 pm
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

Re: Quick question on abstract methods

Posted: Wed Jul 16, 2008 1:37 pm
by VirtuosiMedia
WebbieDave wrote: No, the signatures must match.
Thanks.