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
|
<?php
class User
{
//attribut
public $name;
private $password, $lastLogin;
//méthode
public function __construct($name, $password)
{
$this->name = $name;
$this->password = $password;
$this->lastLogin = time();
$this->accesses++;
//c'est ça je ne sais pas pourquoi,car si je supprime cette ligne,y a rien changement
}
// récuperer la dernière date
function getLastLogin()
{
return(date("M d Y", $this->lastLogin));
}
}
$user = new User("toto", "ohlala");
print("$user->name<br>\n");
print($user->getLastLogin() ."<br>\n");
?> |
Partager