class SaeedPoureshghi{
public $birthdate = '1982/03/14';
private $nationality = 'Iranian';
public function Age() {
$now = date_create();
$birthday = date_create($this->birthdate);
$diff = date_diff($now,$birthday);
return $diff->format("%y YearsOld!");
}
public function getNationality() {
return $this->nationality;
}
}
$sp = new SaeedPoureshghi();
echo 'I am '.$sp->Age().' and an '.$sp->getNationality();
//output
I am 42 YearsOld! and an Iranian
$sp = new SaeedPoureshghi();
$result = 'I am '.$sp->Age();
$result .= ' and an '.$sp->getNationality();
echo $result;
//output
I am 42 YearsOld! and an Iranian
سلام ، من سعید پورعشقی هستم
یک توسعه دهنده وب و موبایل!
All Rights Reserved 2024