Created
October 17, 2018 07:19
-
-
Save Karnak19/d8965a9c9254f397fce3459a28ee957d to your computer and use it in GitHub Desktop.
This file contains hidden or 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 $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