General statement: ¥this indicates that the current class object is very ambiguous
$this depends on the execution object (environment) when the ¥this method is called
Method execution Environment: in which object environment the current method executes, the ¥this of the method represents the object for restoring layers to the most initial method
Example
Class a{
Private Function M () {
echo ' AA ';
}
Public Function run () {
Var_dump ($this);
}
}
$ai = new A ();
$ai->run ();
echo "
=======
";
Class b{
Public Function m () {
Var_dump ($this);
Echo '
';
A::run ();
}
}
$li = new B ();
$li->m ();
?>
But if it's inherited, the Run method comes from inheritance, so this is the Class A
Class a{
Private Function M () {
echo ' AA ';
}
Public Function run () {
$this->m ();
}
}
Class B extends a{
Public Function m () {
Echo ' BB ';
}
}
$li = new B ();
$li->run ();
?>
The above describes the PHP $this exactly what, including the content, I hope that the PHP tutorial interested in a friend helpful.