note 95590 deleted from language.oop5.interfaces by danbrown

From: Date: Mon, 11 Jan 2010 14:48:47 +0000
Subject: note 95590 deleted from language.oop5.interfaces by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-164856@lists.php.net to get a copy of this message
Note Submitter: btjakachira at gmail dot com ---- A couple of changes from the post below An interface can be used in more than one inheritence. That is two totally different objects can use any interface Example consider following objects. <?php Fruit -> Apple Vehicle -> Car ?> Say after the application has been develeoped, you decide to add a transport() functionality for all Fruits and Vehicles The above two objects Apple and Car can implements <?php interface Shipping { public function transport($method); } class Apple implements Shipping extends Fruit { public function transport($method) { //transport apples } } class Car implements Shipping extends Vehicle { public function transport($method) { //transport cars } } Car c = new car(); c.transport("rail"); //you can transport cars Apple a = new Apple(); a.transport("air"); //you can also transport apples ?> Therefore you also use interface to add functionality to already created objects that are not the same. By doing this you will not have to define the transport method to all abstract or parent classes..

« previous php.notes (#164856) next »