<?php abstract class Person { public string $firstName {get => $this->getFirstName();} public string $lastName {get => $this->getLastName();} public string $fullName { get => $this->firstName . ' ' . $this->lastName; } abstract protected function getFirstName(): string; abstract protected function getLastName(): string; } class Mark extends Person { protected function getFirstName(): string { return 'Mark'; } protected function getLastName(): string { return 'Zukarberger'; } } $mark = new Mark(); var_dump( $mark->firstName, $mark->lastName, $mark->fullName, );
You have javascript disabled. You will not be able to edit any code.