-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoop.php
71 lines (54 loc) · 1.37 KB
/
oop.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
class Person {
private $name;
private $email;
private static $ageLimit = 40;
public function __construct($name, $email) {
$this->name = $name;
$this->email = $email;
echo __CLASS__.' created<br>';
}
public function __destruct() {
echo __CLASS__.' destroyed<br>';
}
public function setName($name) {
$this->name = $name;
}
public function getName() {
return $this->name.'<br>';
}
public function setEmail($email) {
$this->email = $email;
}
public function getEmail() {
return $this->email.'<br>';
}
public static function getAgeLimit() {
return self::$ageLimit;
}
}
# Static properties and methods
// echo Person::$ageLimit;
echo Person::getAgeLimit();
// $person1 = new Person('John Doe', 'john@gmail.com');
// $person1->setName('John Doe');
// echo $person1->getName();
// $person1->name = "John Doe";
// echo $person1->name;
class Customer extends Person {
private $balance;
public function __construct($name, $email, $balance) {
parent::__construct($name, $email);
$this->balance = $balance;
echo 'A new '.__CLASS__.' has been created<br>';
}
public function setBalance($balance) {
$this->balance = $balance;
}
public function getBalance() {
return $this->balance.'<br>';
}
}
// $customer1 = new Customer('John Doe', 'john@gmail.com', 300);
// echo $customer1->getBalance();
?>