-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphp_3.3.php
61 lines (54 loc) · 1.73 KB
/
php_3.3.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
<?
abstract class Country{
protected $slogan;
function sayHello() {}
public function getSlogan() {
return $this->slogan;
}
public function setSlogan($slogan) {
$this->slogan = $slogan;
}
}
trait Active {
public function defineYourself() {
return get_class($this);
}
}
interface Boss {
public function checkValidSlogan();
}
class EnglandCountry extends Country implements Boss {
use Active;
public function sayHello(){
return ("Hello");
}
public function checkValidSlogan() {
return (strpos(" ".$this->slogan, "England") or strpos(" ".$this->slogan, "English"));
}
}
class VietnamCountry extends Country implements Boss
{
use Active;
public function sayHello()
{
return ("Xin chao");
}
public function checkValidSlogan()
{
return (strpos(" " . $this->slogan, "Vietnam") or strpos(" " . $this->slogan, "Vietnamese"));
}
}
$englandCountry = new EnglandCountry();
$vietnamCountry = new VietnamCountry();
$englandCountry->setSlogan('England is a country that is part of the United Kingdom. It shares land borders with Wales to the west and Scotland to the north. The Irish Sea lies west of England and the Celtic Sea to the southwest.');
$vietnamCountry->setSlogan('Vietnam is the easternmost country on the Indochina Peninsula. With an estimated 94.6 million inhabitants as of 2016, it is the 15th most populous country in the world .');
var_dump($englandCountry->sayHello()); // Hello
echo "<br>";
var_dump($vietnamCountry->sayHello()); // Xin chao
echo "<br>";
var_dump($englandCountry->checkValidSlogan()); // true
echo "<br>";
var_dump($vietnamCountry->checkValidSlogan()); // false
echo 'I am ' . $englandCountry->defineYourSelf();
echo "<br>";
echo 'I am ' . $vietnamCountry->defineYourSelf();