Home >Backend Development >PHP Tutorial >Differences between php this, self and parent
1. this is a pointer to the current object
For example: other functions in the same class can be called with this->function name.
2. Self is a pointer to the current class
Generally, self is used to point to static variables in the class. Also note that using self to call static variables must use:: (field operation symbol)
For example: self::$firstCount; //Use self to call static variables
3. Parent is a pointer to the parent class
Generally we use parent to call the constructor of the parent class
For example: parent::__construct( "PBPHome"); //Use parent to call the constructor of the parent class