Solution Review: Inheritance
Let's look at the solution of the Inheritance challenge.
We'll cover the following...
Solution
Press + to interact
<?phpclass User {protected $username;public function setUsername($name) {$this -> username = $name;}}class Admin extends User {public function expressYourRole() {return strtolower(__CLASS__);}public function sayHello() {return "Hello admin, " . $this -> username;}}function test(){$admin1 = new Admin();$admin1 -> setUsername("Balthazar");return $admin1 -> sayHello();}echo test();?>
Explanation
-** Line 2:** We create a ...