php class User public name public login public password public functio

 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
<?php
class User{
public $name;
public $login;
public $password;
public function __construct($name, $login, $password){
$this->name = $name;
$this->login = $login;
$this->password = $password;
}
public function __destruct(){
echo 'Пользователь [' . $this->login . '] удален.<br>';
}
public function __clone(){
$this->name = '';
$this->login = '';
$this->password = '';
}
public function showInfo(){
echo $this->name.' '.$this->login.' '.$this->password.'<br>';
}
}
$user1 = new User('Admin', 'admin', '12345');
$user2 = new User('Vasya', 'vasya', 'qwerty');
$user3 = new User('Petya', 'petya', '123');
$user1->showInfo();
$user2->showInfo();
$user3->showInfo();
$user4 = clone $user2;
$user4->showInfo();
?>