Created
September 19, 2016 16:43
-
-
Save Ludovicmoreau/0f64b82bf6706bbb2a98c48a2b865c5e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Personne{ | |
public $nom = ''; | |
public $prenom =''; | |
public $adresse = ''; | |
public $datedenaissance = ''; | |
public function __construct ( $nom, $prenom, $adresse, $datedenaissance){ | |
$this->nom = $nom ; | |
$this->prenom = $prenom ; | |
$this->adresse = $adresse ; | |
$this->datedenaissance = $datedenaissance ; | |
} | |
public function affichePersonnage(){ | |
return $this->nom.' '. | |
$this->prenom.' '. | |
$this->adresse.' '. | |
$this->datedenaissance; | |
} | |
public function nouvelleAdresse(){ | |
return $this->adresse = 'BLA'; | |
} | |
function Age(){ | |
$this->datedenaissance = explode("/", $this->datedenaissance); | |
$age = (date("md", date("U", mktime(0, 0, 0, $this->datedenaissance[0], $this->datedenaissance[1], $this->datedenaissance[2]))) > date("md") | |
? ((date("Y") - $this->datedenaissance[2]) - 1) | |
: (date("Y") - $this->datedenaissance[2])); | |
echo "Age is:" . $age; | |
} | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'class.php' ; | |
$ludovic = new Personne('MOREAU', 'Ludovic', 'Orléans', '1994') ; | |
echo $ludovic->affichePersonnage(); | |
echo $ludovic->nouvelleAdresse(); | |
echo $ludovic->Age(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment