Home > Backend Development > PHP Tutorial > Differences between php this, self and parent

Differences between php this, self and parent

巴扎黑
Release: 2016-11-12 11:38:48
Original
1423 people have browsed it

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


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template