1class Shape {
2 const Pi = 3.142 ; // constant value
3 function __call($functionname, $argument){
4 if($functionname == 'area')
5 switch(count($argument)){
6 case 0 : return 0 ;
7 case 1 : return self::Pi * $argument[0] ; // 3.14 * 5
8 case 2 : return $argument[0] * $argument[1]; // 5 * 10
9 }
10
11 }
12
13 }
14 $circle = new Shape();`enter code here`
15 echo "Area of circle:".$circle->area()."</br>"; // display the area of circle Output 0
16 echo "Area of circle:".$circle->area(5)."</br>"; // display the area of circle
17 $rect = new Shape();
18 echo "Area of rectangle:".$rect->area(5,10); // display area of rectangle
19
1<?php
2
3class Foo {
4 function myFoo() {
5 return "Foo";
6 }
7}
8
9class Bar extends Foo {
10 function myFoo() {
11 return "Bar";
12 }
13}
14
15$foo = new Foo;
16$bar = new Bar;
17echo($foo->myFoo()); //"Foo"
18echo($bar->myFoo()); //"Bar"
19?>
20