Solution Review: Chaining Methods and Properties
Let's look at the solution of the Chaining Methods and Properties challenge.
We'll cover the following...
Solution
Press + to interact
<?phpclass User {public $firstName;public function hello() {echo "hello, " . $this -> firstName;return $this;}public function register() {echo " >> registered";return $this;}public function mail() {echo " >> email sent";}}function test(){$user1 = new User();$user1 -> firstName = "Jane";$user1 -> hello() -> register() -> mail();}test();?>
Explanation
- Line 2: