-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask1.php
More file actions
37 lines (30 loc) · 725 Bytes
/
Task1.php
File metadata and controls
37 lines (30 loc) · 725 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
class shape{
protected function area()
{}
}
class Circle{
protected $Radius;
function __construct($r)
{
$this->Radius=$r;
}
public function area()
{
echo "The area of a circle is: ". M_PI * pow($this->Radius,2)."<br><br>";
}
}
class Rectangle{
public $height,$width;
function __construct($h,$w){
$this->height=$h;$this->width=$w;
}
public function area(){
echo "The area of a rectangle is: ".$this->height*$this->width."<br>";
}
}
$obj1= new Circle(5);
$obj1->area();
$obj2= new Rectangle(5,8);
$obj2->area();
?>