Home  >  Article  >  Backend Development  >  php this、self、parent差异

php this、self、parent差异

WBOY
WBOYOriginal
2016-06-13 11:57:31891browse

php this、self、parent区别

1、this是指向当前对象的指针如:同class里面的其他函数可以用 this->函数名 调用。2、self是指向当前类的指针一般self使用来指向类中的静态变量,还要注意使用self来调用静态变量必须使用:: (域运算符号)如:self::$firstCount;      //使用self来调用静态变量3、parent是指向父类的指针一般我们使用parent来调用父类的构造函数如:parent::__construct( "PBPHome");    //使用parent调用了父类的构造函数

?

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