class DBmodel{ private $name; public __construct(){ $this->name = $name; } public function delete($name){ $this->name = $name; } }
Does $this in __construct represent __construct itself? Does $this in delete represent delete itself? Or does $this represent the entire class?
$this represents the entire class
This object must be allocated using the new operator (not new[], not placement new, not a local object, not a global object); after deleting this, you cannot access any members of the object Variables and virtual functions (delete this recycles data, which includes the object's data members and vtable, excluding function code); after deleting this, the this pointer can no longer be accessed. In other words, you can't check it, compare it to other pointers, compare it to NULL, print it, convert it, or anything else
$this represents an object, and the environment where $this is located is inside the method inside the class, so the $this object is accessed inside the class