note 95590 added to language.oop5.interfaces

From: Date: Mon, 11 Jan 2010 12:41:08 +0000
Subject: note 95590 added to language.oop5.interfaces
Groups: php.notes 
Request: Send a blank email to php-notes+get-164848@lists.php.net to get a copy of this message
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.. ---- Server IP: 69.147.83.197 Probable Submitter: 196.211.45.34 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.interfaces.php Edit -- https://master.php.net/note/edit/95590 Del: integrated -- https://master.php.net/note/delete/95590/integrated Del: useless -- https://master.php.net/note/delete/95590/useless Del: bad code -- https://master.php.net/note/delete/95590/bad+code Del: spam -- https://master.php.net/note/delete/95590/spam Del: non-english -- https://master.php.net/note/delete/95590/non-english Del: in docs -- https://master.php.net/note/delete/95590/in+docs Del: other reasons-- https://master.php.net/note/delete/95590 Reject -- https://master.php.net/note/reject/95590 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#164848) next »