Skip to content

Instantly share code, notes, and snippets.

@muhamadsobari198
Created October 16, 2018 08:16
Show Gist options
  • Save muhamadsobari198/e56eaa632221eccc46bb64c93d7b6f8e to your computer and use it in GitHub Desktop.
Save muhamadsobari198/e56eaa632221eccc46bb64c93d7b6f8e to your computer and use it in GitHub Desktop.
<?php
class Person
{
private $firstName;
private $lastName;
private $age;
public function __construct(string $firstName, string $lastName, int $age)
{
$this->firstName = $firstName;
$this->lastName = $lastName;
$this->age = $age;
}
public function getFullName(): string
{
return "{$this->firstName} {$this->lastName}";
}
public function describe(): string
{
return "Hello {$this->getFullName()}, this is your age: {$this->age}";
}
}
$person = new Person('Jan Joshua', 'Esmer', 25);
echo $person->describe();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment