Home >Backend Development >PHP Tutorial >Introduction to the differences between operators::, ->, self and $this in PHP_PHP Tutorial

Introduction to the differences between operators::, ->, self and $this in PHP_PHP Tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-21 15:11:56843browse

When accessing member variables or methods in a PHP class, if the referenced variable or method is declared as const (defining constant) or static (declaring static), then you must use the operator::, otherwise if the referenced variable or method If the method is not declared const or static, the operator -> must be used.

In addition, if you access a const or static variable or method from within the class, you must use self-reference. On the contrary, if you access a non-const or static variable or method from within the class, you must use self. Self-referential $this.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/326811.htmlTechArticleWhen accessing member variables or methods in a PHP class, if the referenced variable or method is declared as const ( Define constant) or static (declare static), then you must use the operator:...
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