RE: [PHP] Re: Polymorphism in PHP

From: Date: Mon, 18 Feb 2002 20:15:42 +0000
Subject: RE: [PHP] Re: Polymorphism in PHP
Groups: php.general 
Request: Send a blank email to php-general+get-85267@lists.php.net to get a copy of this message
I must be missing something in your question, because I just tried your script below and it worked as advertised. Did you try the script and it failed? -----Original Message----- From: Richard Fox [mailto:rfox@sbsii.com] Sent: Monday, February 18, 2002 2:13 PM To: PHP Subject: [PHP] Re: Polymorphism in PHP That's right, the difference between C++ "pure virtual" and "virtual" is that a virtual function has an implementation but pure virtual only defines an interface. But can we get back to my original PHP question: Can I do something like the following in php: class Base { function Foo() { echo "Base"; } } class Derived1 extends Base { function Foo() { echo "Derived1"; } } class Derived2 extends Base { function Foo() { echo "Derived2"; } } function Example ( $objvar ) { $objvar->Foo(); } ... $obj1 = new Base(); $obj2 = new Derived1(); $obj3 = new Derived2(); Example($obj1); Example($obj2); Example($obj3); I think what I am asking is, is there any concept of a virtual function in PHP, with a virtual function table? Rich -----Original Message----- From: Martin Towell [mailto:martin.towell@world.net] Sent: Sunday, February 17, 2002 5:31 PM To: php-general@lists.php.net Subject: RE: [PHP] Polymorphism question A bit late in replying - but what the hay (or is that "hey"??) oh well... >From my understanding of virtual functions (and it's been at least 3 to 4 years since I've done C++) is that a "virtual function" has basic functionality and a "pure virtual function" has no, and can't have, and code. Please correct me if I'm wrong Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#85267) next »