Overriding the Function of a Base Class : Override « Functions « PHP






Overriding the Function of a Base Class

<?php
  class vehicle {
      var $brand_name;
      var $number_of_wheels;
      var $seating_capacity;
    
      function message() {
         echo "the vehicle class";
      }
  }
  
  class car extends vehicle {
      var $doors;
      var $rooftype;
      var $powersteering;
      var $powerwindows;
      
      function message() {
         echo "the car class";
      }
  }

  $merk= new car;
  $merk->message();
?>

           
       








Related examples in the same category

1.Calling an Overridden Function