-
Notifications
You must be signed in to change notification settings - Fork 12
/
intro.php
62 lines (48 loc) · 1.27 KB
/
intro.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
<?php
class User {
protected $name;
protected $title;
public function __construct($name, $title) {
$this->name = $name;
$this->title = $title;
}
public function __toString() {
return $this->getFormattedSalutation();
}
public function getFormattedSalutation() {
return $this->getSalutation();
}
protected function getSalutation() {
return $this->title . " " . $this->name;
}
public function getName() {
return $this->name;
}
public function setName($name) {
$this->name = $name;
}
public function getTitle() {
return $this->title;
}
public function setTitle($title) {
$this->title = $title;
}
}
class Developer extends User {
public $skills = array();
public function getSalutation() {
return $this->title . " " . $this->name.", Developer";
}
public function getSkillsString() {
echo implode(", ",$this->skills);
}
}
$user = new User("Jane Doe","Ms");
echo $user;
echo "<br />";
$developer = new Developer("Jane Doe", "Ms");
echo $developer;
echo "<br />";
$developer->skills = array("JavasScript", "HTML", "CSS");
$developer->skills[] = "PHP";
$developer->getSkillsString();