Skip to content

Instantly share code, notes, and snippets.

@Karnak19
Created October 17, 2018 07:19
Show Gist options
  • Select an option

  • Save Karnak19/d8965a9c9254f397fce3459a28ee957d to your computer and use it in GitHub Desktop.

Select an option

Save Karnak19/d8965a9c9254f397fce3459a28ee957d to your computer and use it in GitHub Desktop.
<?php
class personne {
public $nom;
public $prenom;
public $date;
public $adresse;
public function getInfos() {
echo $this->nom.' '.$this->prenom.' '.$this->date.' '.$this->adresse;
}
public function setAdresse($newAdresse) {
$this->adresse = $newAdresse;
return $this;
}
public function getAge() {
$birthDate = $this->birthDate;
$birthDate = explode("/", $birthDate);
//get age from date or birthdate
$age = (date("md", date("U", mktime(0, 0, 0, $birthDate[0], $birthDate[1], $birthDate[2]))) > date("md")
? ((date("Y") - $birthDate[2]) - 1)
: (date("Y") - $birthDate[2]));
echo "Age is:" . $age;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment