Is it because I did not add this ah I see people say if not add this is understood as a local variable inside the method of the sentence how to understand AH is not the error? So why do you get an error? I'm a novice, and I'm feeling object-oriented.
who();?>
Reply content:
Is it because I did not add this ah I see people say if not add this is understood as a local variable inside the method of the sentence how to understand AH is not the error? So why do you get an error? I'm a novice, and I'm feeling object-oriented.
who();?>
No add this can be recognized as a class variable that is the Java rule. The use of class variables in PHP must prefix this.
1, the Who method inside the $name is indeed an undefined variable, you can use Isset ($name) to determine whether the value of the variable is set.
2. The $name of the Who method does not add $this, but $name must be initialized!!! such as $name = ' Zhangsan '; echo $name; then $name is the local variable in the Who method.
3. The Who method adds $this, that is, Echo $this->name, then accesses the properties of the class.