php中this、self、parent三种指针的区别是什么?
大神,求带!
大神,求带! 2017-02-16 09:28:58
0
2
927

php中this、self、parent三种指针的区别是什么?

大神,求带!
大神,求带!

reply all(2)
数据分析师

What are the differences between this, self, and parent pointers in php? -PHP Chinese website Q&A-What are the differences between this, self, and parent pointers in PHP? -PHP Chinese website Q&A

Let’s take a look and learn.

伊谢尔伦

1、this是指向当前对象的指针

如:同class里面的其他函数可以用

this->函数名

调用。

2、self是指向当前类的指针

一般self使用来指向类中的静态变量,还要注意使用self来调用静态变量必须使用:: (域运算符号)

如:

self::$firstCount;      //使用self来调用静态变量

3、parent是指向父类的指针

一般我们使用parent来调用父类的构造函数

如:

parent::__construct("PBPHome");    //使用parent调用了父类的构造函数


Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template