Polymorphism [was] [Fwd: Re: [PHP] Parents constructor]
| From: | Jochem Maas | Date: | Wed, 03 May 2006 14:17:05 +0000 |
| Subject: | Polymorphism [was] [Fwd: Re: [PHP] Parents constructor] | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-235370@lists.php.net to get a copy of this message | ||
-------- Original Message --------
On Fri, 2006-03-24 at 10:50, Jochem Maas wrote:
Pham Huu Le Quoc Phuc wrote: I want to execute polymorphism.I said (a long time ago):
...BUT the OP didn't ask about polymorphism and php doesn't support it at all anyway.Rob replied (also quite a long time ago):
Ummm, PHP supports polymorphism.. it has at least since PHP 4.PHP supports 1 - but I have never heard of dynamic typing referred to as polymorphism. PHP doesn't support 2 - in so far as you can't define mabny functions with the same name (but different signatures) - this is usually referred to as overloading. - granted we have __call() on objects/classes which allows you to implement functionality that work like this.http://whatis.techtarget.com/definition/0,,sid9_gci212803,00.html1 and 3 in the above link are supported. Number 2 is not, however, that
is usually referred to as function/method overloading and not so often by polymorphism. Number 3 is the most common type when discussing polymorphism.in php's case this comes down to the same thing as 1. - dynamic typing of variables. BUT there is a fourth form of polymorphism - one I would argue if the most common form when speaking about polymorphism with respect to programming, namely the ability to derive a subclass from more than one base class (simutaneously), this is something that php cannot do (thank <deity>).
Cheers, Rob.