Created
November 3, 2017 11:18
-
-
Save saraclima/cb6fc6d1278241fbc080e00605d519c3 to your computer and use it in GitHub Desktop.
Quete_Poo
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 'Personne.php'; | |
$pers1 = new Personne('Karl', 'Furlein','rue du lavoisier', '1960-03-12'); | |
$pers1->setAdress('1, rue du bordel'); | |
$pers1->afficher(); | |
$pers1->calculAge(); |
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 $datedn; | |
public function __construct($nom,$prenom,$adresse,$datedn) | |
{ | |
$this->nom = $nom; | |
$this->prenom = $prenom; | |
$this->adresse = $adresse; | |
$this->datedn = $datedn; | |
} | |
public function afficher(){ | |
echo 'Nom :',$this->nom . "<br>"; | |
echo 'Prenom :',$this->prenom . "<br>"; | |
echo 'Adresse :',$this->adresse . "<br>"; | |
echo 'Date de naissance :',$this->datedn . "<br>"; | |
} | |
public function calculAge() { | |
$dateNow = new DateTime('now'); | |
$datedn2 = new DateTime('1960-03-12'); | |
$intervale = $dateNow->diff($datedn2); | |
echo "<br>âge =". $intervale->format('%y'); | |
} | |
public function setAdress($adresse) | |
{ | |
$this->adresse=$adresse; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment