Advertisement
Guest User

Untitled

a guest
Sep 25th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. <?php
  2.  
  3. class Personne{
  4.  
  5. public $_nom = 'Jones';
  6. public $_prenom = 'Bridget';
  7. public $_adresse = '1 rue des Fermettes';
  8. public $_datenaissance = [17, 10, 1989];
  9. private $_annee = '2016';
  10.  
  11. public function afficherInfos (){
  12.  
  13. return $this->_nom . '<br />'
  14. . $this->_prenom . '<br />'
  15. . $this->_adresse . '<br />'
  16. . $this->_datenaissance[0] . '/' . $this->_datenaissance[1] . '/'
  17. . $this->_datenaissance[2] . '<br/>';
  18. }
  19.  
  20. public function changerAdresse ($nouvelleAdresse) {
  21.  
  22. $this->_adresse = $nouvelleAdresse;
  23. return $this->_adresse;
  24. }
  25.  
  26. public function calculAge() {
  27.  
  28. $age = $this->_annee - $this->_datenaissance[2];
  29. return $age . 'ans';
  30. }
  31. }
  32.  
  33. $bridget = new Personne;
  34. echo $bridget->afficherInfos();
  35. $bridget->changerAdresse('300 Avenue de la Gloire');
  36. echo $bridget->afficherInfos();
  37. echo $bridget->calculAge();
  38.  
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement