Saturday 13 February 2016

Function Overriding

Code:

<?php
class Ice {
   function myFun() {
      return "Ice";
   }
}

class Cream extends Ice {
   function myFun() {
      return "Cream";
   }
}

$ice = new Ice;
$cream = new Cream;
echo "<center><h1>Function Overriding</h1>";
echo($ice->myFun());
echo($cream->myFun());
echo "</center>";
?>



Output:

No comments:

Post a Comment