Switch to full style
:read: Start PHP with us. Includes topics to help you in php
Post a reply

Calling an Overridden Method in php

Mon Oct 27, 2008 12:03 am

Code:
<?php
  
class Rectangle {
    
public $height;
    
public $width;
   
    
public function __construct($width, $height) {
      
$this->width = $width;
      
$this->height = $height;
     }
    
     
public function getArea() {
      return
$this->height * $this->width;
     }
   }

  class
Square extends Rectangle {
    
public function __construct($size) {
      
$this->height = $size;
      
$this->width = $size;
    }
   
    
public function getArea() {
      return
pow($this->height, 2);
    }
   
  }

$obj = new Square(7);
$a = $obj->getArea();
echo
"$a";

?>




Post a reply
  Related Posts  to : Calling an Overridden Method in php
 Calling an Overridden Function     -  
 Calling a Private Method in jsp     -  
 calling method to form- displaying textbox data in messagbox     -  
 Calling the man Command     -  
 Calling other programs from java     -  
 Calling Overloaded Methods     -  
 Calling Functions Dynamically     -  
 CME display calling number without leading 0     -  
 Calling a local variable from a static function     -  
 overriding method in php     -  

Topic Tags

PHP OOP