OOP: Interface : Multiple Implementation

Objectives:

  • Class extends another Class
  • Class implements an Interface
  • Interface extends another Interface
  • this example is reproduced in windows 7 64 bit / apache2.2 / PHP 5.2-as a module

Code:

<?php
interface team1
{
// keep the names different PHP can not resolve
//conflict using .operator as cab done with C#
public function team1_lineup();
}

interface team2
{
public function team2_lineup();
}
// extending interface key word extends
interface club extends team1, team2
{
public function manage();
}
// key word implemnt used when diferent objects are inherited
//class would extend a class
//class would implement an interface
class Test implements club
{
// attributes
public $city = "Chicago";
public $day ="Monday , at 5.00 pm";
public $place ="UIC-Stadium";

public function team1_lineup()
{
echo "<br/><font style='color:Green;'> team 1 : ready </font>";
}

public function team2_lineup()
{
echo "<br/><font style='color:Red;'> team 2 : ready </font>";
}

public function manage()
{
echo "<br/><font style='color:Navy;'> ref is : ready </font>";
}
}
echo "<u> Checking Method line by line</u>";
$obj1= new Test();
$obj1->team1_lineup();
$obj1->team2_lineup();
$obj1->manage();
// chcking attributes
echo "<br/><u> Checking Attributes</u>";
foreach($obj1 as $attribute)
{
echo "<br/>". $attribute ;
}
echo "<br/> -------done--C:U------";
?>

Runtime