This is the pointer to the current object [php] viewplaincopyprint? & Lt ;? Phpclasshuman {public $ name = & quot; & quot; publicfunctioneat () {echo $ this-& gt; name, & amp; #39; eat & amp; #39;} pu
This is the pointer to the current object [php] view plaincopyprint?
Class human {
Public $ name = "Li Si ";
Public function eat (){
Echo $ this-> name, 'At dinner ';
}
Public function test (){
Echo $ name, 'At dinner ';
}
}
$ Li = new human ();
Echo $ li-> name; // li Si
$ Li-> eat (); // li Si is eating.
/*
Compared with java and c ++
You must use $ this
If this parameter is not added, it is considered as a local variable in the method.
*/
$ Li-> test (); // Notice: Undefined variable: name in C: \ wamp \ www \ php \ this. php on line 14
/******
Understanding $ this from the perspective of life
A "remorse" method was created when the NVWA was created.
{
Capture your hair
Smoke your own face
}
There are so many people in the world,
Who's the hair when I regret it?
Who's the face?
Zhang San, Li Si? Wang Wu? Cannot describe reasonable situations
It can only be understood as "yourself"
******/
?>
Class human {
Public $ name = "Li Si ";
Public function eat (){
Echo $ this-> name, 'At dinner ';
}
Public function test (){
Echo $ name, 'At dinner ';
}
}
$ Li = new human ();
Echo $ li-> name; // li Si
$ Li-> eat (); // li Si is eating.
/*
Compared with java and c ++
You must use $ this
If this parameter is not added, it is considered as a local variable in the method.
*/
$ Li-> test (); // Notice: Undefined variable: name in C: \ wamp \ www \ php \ this. php on line 14
/******
Understanding $ this from the perspective of life
A "remorse" method was created when the NVWA was created.
{
Capture your hair
Smoke your own face
}
There are so many people in the world,
Who's the hair when I regret it?
Who's the face?
Zhang San, Li Si? Wang Wu? Cannot describe reasonable situations
It can only be understood as "yourself"
******/
?>