Last active
March 25, 2019 11:32
-
-
Save ConnorFM/05871513158bda84da4fcbe7d05ae2bb 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 | |
{ | |
// Attributes | |
public $name; | |
public $firstName; | |
public $adress; | |
public $birthDate; | |
//Methods | |
public function getInfos(){ | |
return $this->firstName . " " . $this->name . " is born on " . $this->birthDate . " and lives in " . $this->adress; | |
} | |
public function setAdress($newAdress){ | |
$this->adress= $newAdress; | |
return $this->getInfos() | |
} | |
public function age(){ | |
return $this->firstName . " is " . floor((time() - strtotime($this ->birthDate)) / 3600 / 24 / 365) . " years old"; | |
} | |
} | |
$foucauld = new Personne(); | |
$foucauld->name = 'Gaudin'; | |
$foucauld->firstName = 'Foucauld'; | |
$foucauld->adress = 'Tassin'; | |
$foucauld->birthDate = '24-07-1988'; | |
echo $foucauld->getInfos(); | |
echo '</br>'; | |
echo $foucauld->setAdress('Lyon'); | |
echo '</br>'; | |
echo $foucauld->age(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment