Skip to content

Instantly share code, notes, and snippets.

@saraclima
Created November 3, 2017 11:18
Show Gist options
  • Save saraclima/cb6fc6d1278241fbc080e00605d519c3 to your computer and use it in GitHub Desktop.
Save saraclima/cb6fc6d1278241fbc080e00605d519c3 to your computer and use it in GitHub Desktop.
Quete_Poo
<?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();
<?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