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
Release: 2016-07-25 09:12:21
Original
996 people have browsed it

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


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