-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphpclass.php
33 lines (26 loc) · 912 Bytes
/
phpclass.php
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
<?php
class Continent {
public $name;
public $currency;
public $religion;
public function __construct($name, $currency, $religion) {
$this->name = $name;
$this->currency = $currency;
$this->religion = $religion;
}
public function displayInfo() {
echo "Name: " . $this->name . ", Currency: " . $this->currency . ", Religion: " . $this->religion . "<br>";
}
}
class Country extends Continent {
public function displayArea() {
echo "The country " . $this->name . " is in africa and majority practice " . $this->religion . ".<br>";
}
}
// Create an instance of the Country class
$myCountry = new Country("Ghana", "Cedi", "Christianity");
// Use the displayInfo method from the parent class
$myCountry->displayInfo();
// Use the displayArea method from the Country class
$myCountry->displayArea();
?>