PHP 中 new static 和 new self 的区别
来源:互联网 发布:软件测试行业现状 编辑:程序博客网 时间:2024/05/16 16:09
lass A {public static function get_self() {return new self();}public static function get_static() {return new static();}}class B extends A {}echo get_class(B::get_self()); // Aecho get_class(B::get_static()); // Becho get_class(A::get_static()); // Anew self 那么获取的是当前代码段的这个类。 这个在class A 中写的方法 就算你在class B 中继承了,调用时返回的还是 class A 中的代码new static PHP 5.3新增的方法,有点 $this 的味道,调用对应的 class 就返回 对应 class 的方法。
阅读全文
0 0
- PHP中new static() 和 new self() 的区别
- PHP中new self()和new static()的区别探究
- PHP中new self()和new static()的区别
- PHP 中 new static 和 new self 的区别
- PHP中new static()与new self()的区别
- PHP中new static()与new self()的区别
- PHP中new static() 和 new self()
- 【PHP趣味】new self和new static的区别
- PHP中new static()与new self()
- PHP中new static()与new self()的区别异同分析
- PHP中new static()与new self()的区别异同分析
- PHP中new static()与new self()的区别异同分析
- PHP中new static()与new self()的区别异同分析
- PHP中new static()与new self()的区别及5.2版本重写5.3
- PHP中new static()与new self()的区别异同分析
- new self 与 new static 的区别
- new self() 与new static()的区别
- PHP的self::与static::,new self()和new static()之分
- bootstrap模态框添加滚动条
- 图文混编
- sqoop ERROR tool.ImportTool: Error during import: Import job failed!
- tensorflow实现最基本的神经网络 + 对比GD、SGD、batch-GD的训练方法
- 今天偶尔逛delphi的论坛,看到的json文章,收藏
- PHP 中 new static 和 new self 的区别
- iOS定时器取消,用在socket断线重连
- 线性回归、岭回归、逻辑回归、信息量与熵、多类的分类问题softmax、链式法则与BP神经网络
- Vysor 破解
- 谈谈shuffle流程 细节就不说了
- Ruby学习笔记(23)_Capybara Actions
- 五金:常用电线规格标准统计(UL,AWG)
- 《C++ Primer》学习笔记 第9章:顺序容器
- 推荐10 个短小却超实用的 JavaScript 代码段