关于PHP中static和self的区别
来源:互联网 发布:淘宝兼职画师 编辑:程序博客网 时间:2024/05/14 03:11
之前看过一次,但是忘了static和self的具体区别了,这次在复习一下。
static是PHP5.3之后加进来的,看一下英文的解释:
self refers to the same class whose method the new operation takes place in.
static in PHP 5.3's late static bindings refers to whatever class in the hierarchy which you call the method on.
之前看过一个文章这个例子很好:class A { public static function who() { echo __CLASS__; } public static function test() { self::who();// static::who(); }}A::test();class B extends A { public static function who() { echo __CLASS__; }}echo B::test();
self:静态方法,指向本身存在的类
static:指向调用它的类
还是很容易理解的,下次不能再忘了。
0 0
- 关于PHP中static和self的区别
- PHP中 static 和 self 的区别
- PHP 中 static 和 self 的区别
- PHP中SELF和STATIC的区别
- 【PHP】PHP中static和self的区别
- PHP中new static() 和 new self() 的区别
- PHP中this,self和static的区别
- PHP中new self()和new static()的区别探究
- PHP类中static 和self的使用区别
- PHP中new self()和new static()的区别
- PHP 中 new static 和 new self 的区别
- php中self与static的区别
- PHP 中 this self static 的区别
- php类中 self parent static的区别
- PHP中new static()与new self()的区别
- PHP中new static()与new self()的区别
- PHP中static 跟self的使用区别
- PHP中static关键字以及与self关键字的区别
- AngularJS的学习--$on、$emit和$broadcast的使用
- 在Linux系统中安装Go语言的详细教程
- hdu4513最长递增回文串
- 数据结构与算法基础总结
- 常见问题汇总
- 关于PHP中static和self的区别
- SGU 134 Centroid(树形DP)
- SpringBoot配置Email发送功能
- PAT1016部分A+B (15)
- interface and abstract class in java
- 计算机图形学(二)输出图元_3_画线算法_1_直线方程
- 荀策网络:“互联网+”还是“+互联网”?
- redisTemplate 操作及相关配置
- oracle 行转列,列转行