⊗ppOpBsMP 5 of 107 menu

Method Parameters in PHP

Since a method is essentially a regular function, it can accept parameters just like all functions. Let's make our method show from the previous lesson accept some string as a parameter and add '!!!' to its end:

<?php class User { public $name; public $age; public function show($str) { return $str . '!!!'; } } ?>

Let's create a user object:

<?php $user = new User; $user->name = 'john'; $user->age = 25; ?>

Let's call our method:

<?php echo $user->show('hello'); // will output 'hello!!!' ?>

Without looking at my code, implement the same class User with the method show.

bydeenesfrptru