博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
__CLASS__
阅读量:7119 次
发布时间:2019-06-28

本文共 686 字,大约阅读时间需要 2 分钟。

"; } function say_b() { echo "'b' - said the " . get_class($this) . "
"; } } class derived_class extends base_class{ function say_a() { parent::say_a(); echo "'a' - said the " . __CLASS__ . "
"; } function say_b() { parent::say_b(); echo "'b' - said the " . get_class($this) . "
"; } }$obj_b = new derived_class();$obj_b->say_a(); echo "
";$obj_b->say_b();?>

执行结果:

'a' - said the base_class'a' - said the derived_class'b' - said the derived_class'b' - said the derived_class

 

tips:

1.__CLASS__获取的是原汁原味的类名

2.parent()继承父类的代码

本文转自TBHacker博客园博客,原文链接:http://www.cnblogs.com/jiqing9006/p/4096741.html,如需转载请自行联系原作者

你可能感兴趣的文章
C++Primer第5版学习笔记(三)
查看>>
Centos7系统介绍
查看>>
GIT简单实用
查看>>
Sonar - 部署常见问题及解决方法
查看>>
IOS 学习笔记(3) 视图UITabbarController
查看>>
java基础知识(一)
查看>>
(转)Linux传输大文件(分割传输)
查看>>
1003. 我要通过!(20)
查看>>
phpstudy for linux版环境安装
查看>>
MinGW GCC 7.1.0 2017年6月份出炉啦
查看>>
二叉树的实现(Java语言描述)
查看>>
Json Datable Convert
查看>>
微信小程序制作-随笔4
查看>>
adt 22.6出现的问题
查看>>
Struts2(补充)
查看>>
Linux文件系统的目录结构详解
查看>>
MySQL server PID file could not be found!
查看>>
洛谷 P3049园林绿化 题解
查看>>
eclipse New菜单项的显示问题
查看>>
python3常用内置函数总结
查看>>