-
Notifications
You must be signed in to change notification settings - Fork 0
/
sandbox.php
45 lines (35 loc) · 1.04 KB
/
sandbox.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
<?php
## Classes
class User {
# values for User
private $email;
private $name;
# Constructor of User
public function __construct($name, $email)
{
$this->email = $email;
$this->name = $name;
}
# Login function
public function Login() {
// echo 'User logged in.' . '<br />';
echo $this->name . ' logged in.';
}
public function getName() {
return $this->name;
}
public function setName($name) {
if(is_string($name) && strlen($name) > 1) {
$this->name = $name;
return "Name has been updated to $name.";
} else {
return "$name is not a valid name.";
}
}
}
$userTwo = new User('Dutch', 'dutch@vanderlinde.com');
// echo $userTwo->getName() . '<br />';
// echo $userTwo->setName(50);
echo $userTwo->setName('Leopold') . '<br />';
echo $userTwo->getName() . '<br />';
?>