Can someone explain me the $this->
and the ->
and the whole public function __construct
here is my code
<?php
class Person {
public function __construct($firstname, $lastname, $age) {
$this->firstname = $firstname;
$this->lastname = $lastname;
$this->age = $age;
}
public function greet(){
return "Hello, my name is" . $this->firstname . " " .$this->lastname . "Nice to meet you ! :-)";
}
}
$teacher = new Person ("boring", "12345", 12345);
$student = new Person("Mihail", "Dimitrovski", 1995);
echo $student->age;
echo $teacher->greet();
?>