Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class User
- {
- private static $nombre_user = 0;
- private $nom, $address, $telephone;
- public $age;
- public function __construct()
- {
- self::incrementUserCount();
- }
- private static function incrementUserCount()
- {
- self::$nombre_user += 1;
- }
- public static function getNbUser()
- {
- return self::$nombre_user;
- }
- public function getAddress()
- {
- return $this->address;
- }
- public function setAddress($address)
- {
- $this->address = $address;
- }
- public function getTelephone()
- {
- return $this->telephone;
- }
- public function setTelephone($telephone)
- {
- $this->telephone = $telephone;
- }
- public function setNom($nouveau_nom)
- {
- $this->nom = $nouveau_nom;
- }
- public function getNom()
- {
- return $this->nom;
- }
- }
- echo User::getNbUser();
- $blaireau = new User();
- echo User::getNbUser();
- $bogoss = new User();
- echo User::getNbUser();
- $blaireau->setNom("cantin");
- $bogoss->setNom("nicolas");
- echo $blaireau->getNom();
- echo $bogoss->getNom();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement