General statement: ¥this represents the current class object. This is very unclear.
$this depends on the execution object (environment) when the method where ¥this is located is called.
Method execution environment: In which object environment the current method is executed, the The ¥this of the method represents the object. For the object that restores the original method layer by layer, for example
class A{
echo 'aa'; public function run(){
var_dump($this);
}
}
$ai = new A();
$ai->run();
echo "
===== ==
";
class B{
public function m(){ var_dump($this); A::run();
}
}
$li = new B();
$li->m();
?>
But if it is inherited, it will be calculated separately. This run method comes from inheritance, so this is the class a. $this-> m (); ();
$li- >run();
?>
The above introduces what php $this is, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.