Ok so let's say I have a method like so....
And I pass it the first name "John".
I should get back "John Smith".
Code:
public function printName($name) {
$this->fullName = $name . " Smith";
return $this->fullName;
}
But if I do this, I think I would get back
"John Smith" too...
Code:
public function printName($name) {
$fullName = $name . " Smith";
return $fullName;
}
So my question is, what is the significance of "$this->fullName"
in the first example?
I know that it is acting as a reference (pointer) to the name "John Smith" that you are assigning it to. And that "$this->fullName" can be used locally within the method.
Is it ONLY local to the method? Or can other method's use it?
I guess I am missing the point of assigning a variable to "$this->fullName" when you can just create a variable called "$fullname" and return that?