OOP: Reflection :require_once():  interface extend multiple interface

 

Objectives:

  • interface extending another interface
  • interface can extend multiple interface
  • implemented by a class

Codes

<?php
//interface_reflection1.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>";
}
}
?>
 

<?php

require_once 'interface_reflection1.php';
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------";

?>

Runt Time View