class Person
{ public function function1() { return 'from function1'; } public function function2() { $function1 = $this->function1(); echo $function2 = $function1." from function2"; } } $person = new Person(); $person->function2();In the above example class Person have a function named function1.
we want to call it inside another function named fnction2.
function1 return a string. by using $this keyword we can access function from a class
$function1 = $this->function1(); this line access function1 and store the returned
string "from function1" into $function1 variable;
No comments:
Post a Comment