Home >Backend Development >PHP Tutorial >What is the difference between php this, self and parent?

What is the difference between php this, self and parent?

WBOY
WBOYOriginal
2016-07-25 09:12:21990browse

1. this is a pointer to the current object For example: other functions in the same class can be called using this->function name.

2. self is a pointer to the current class Generally, self is used to point to static variables in a class. Please also note that when using self to call static variables, you must use:: (field operator symbol) For example:

  1. self::$firstCount; //Use self to call static variables
Copy code
3. Parent is a pointer to the parent class Generally use parent to call the constructor of the parent class For example:
  1. parent::__construct( "PBPHome"); //Use parent to call the constructor of the parent class
Copy code


Statement:
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