Welcome to the Linux community forum and interact with the 2 million technical staff. this is the pointer to the current object [php] viewplaincopyprint? Classhuman {public $ name Li Si; publicfunctioneat () {echo $ this-name, at dinner;} publicfunctiontest () {echo $ name, at dinner ;}}
Welcome to the Linux community forum and interact with the 2 million technical staff> this is the pointer to the current object [php] view plaincopyprint? Class human {public $ name = ""; public function eat () {echo $ this-name, 'at dinner ';} public function test () {echo $ name, 'At dinner ';}}
Welcome to the Linux community forum and interact with 2 million technicians>
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"
******/
?>