Skip to content

Instantly share code, notes, and snippets.

@ConnorFM
Last active March 25, 2019 11:32
Show Gist options
  • Save ConnorFM/05871513158bda84da4fcbe7d05ae2bb to your computer and use it in GitHub Desktop.
Save ConnorFM/05871513158bda84da4fcbe7d05ae2bb to your computer and use it in GitHub Desktop.
<?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