What is PHP object oriented $ this $ this
First look at where objects and classes are stored in memory
$s = new Saler();
Create the $ s object by instantiating an object through new Saler and pointing $ s to the memory where the object is located,
Instantiation, just copy the attributes of the class to the object space, there is no object method in the object space; ($ this is the object itself in the method member in the class)
Paste a piece of code
<?php class Human{ public $name; public $age; public function __construct($name,$age) { $this->name = $name; $this->age = $age; } public function sayName(){ var_dump($this); } } $man = new Human('Tom',18); $man->sayName(); //object(Human)#1 (2) { ["name"]=> string(3) "Tom" ["age"]=> int(18) }
$ this is the object itself, the method that the object calls the object itself is $ his in time the object itself