__CLASS__
<?php class base_class
{
function say_a()
{
echo "'a' - said the " . __CLASS__ . "<br/>";
} function say_b()
{
echo "'b' - said the " . get_class($this) . "<br/>";
} } class derived_class extends base_class
{
function say_a()
{
parent::say_a();
echo "'a' - said the " . __CLASS__ . "<br/>";
} function say_b()
{
parent::say_b();
echo "'b' - said the " . get_class($this) . "<br/>";
}
} $obj_b = new derived_class(); $obj_b->say_a();
echo "<br/>";
$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()继承父类的代码
__CLASS__的更多相关文章
- python 随笔(property & __class__)
1. 属性装饰器: property @property def errors(self): """ Returns a list of form.errors for ...
- PHP __DIR__, __FILE__, __FUNCTION__, __CLASS__, __METHOD__, __LINE__, __NAMESPACE__
PHP has large number of predefined constants. This HOWTO will present the seven most important, most ...
- php __FILE__,__CLASS__等魔术变量,及实例(转)
今天看到一个魔术变量,是以前没见过的,__DIR__,我查了查,发现原来是php5.3新增的,顺便举几个例子,解释一下php的魔术变量 1,__FILE__ 文件的完整路径和文件名.如果用在被包含文件 ...
- python中self.__class__
1. python中的self python中的self就相当于C++中的this指针也就是指向对象本身的指针self.name = name 就是当前对象的成员变量name赋值为name. 2.py ...
- php __FILE__,__CLASS__等魔术变量,及实例
今天突然看到几个自己不认识的魔术变量 不知道怎么用于是就上网查了一下,看到了这篇博客,写的真不错,希望自己以后也能学会这样总结 张映 发表于 2010-12-13 分类目录: php 标签:php, ...
- get_class __class__ get_called_class 分析记录
首先看代码: class A { use T { T::say as aTsay; } public function say() { echo 'a__class__:' . __CLASS__ . ...
- Python常用内建方法:__init__,__new__,__class__的理解
python中所有类都是继承自object, 而object提供了很多原始的内建属性和方法,所以用户自定义的类在Python中也会继承这些内建属性.可以使用dir()函数可以查看,虽然python提供 ...
- __module__ 和 __class__
__module__ 查看当前方法来之于那个文件 __class__ 查看当前方法来之于那个类
- python __class__属性
>>> class a(object): pass >>> o=a() >>> dir(o) ['__class__', '__delattr__ ...
- __class__属性与元类
class M(type): def __str__(self): return "gege" aa = "ccf" cc = "ccc" ...
随机推荐
- Oracle数据库常用监控语句
--在某个用户下找所有的索引 select user_indexes.table_name, user_indexes.index_name,uniqueness, column_name from ...
- 技术分享:HBase架构
Zookeeper,作为分布式的协调.RegionServer也会把自己的信息写到ZooKeeper中. HDFS是Hbase运行的底层文件系统 RegionServer,理解为数据节点,存储数据的. ...
- codeforces 820A. Mister B and Book Reading 解题报告
题目链接:http://codeforces.com/problemset/problem/820/A 坑爹题目,坑爹题目,坑爹题目....汗 = =! 后台还110个 test 有个地方需要注意下 ...
- [转]HTTP协议通信原理
本文转自<HTTP协议通信原理> 了解HTTP HTTP(HyperText Transfer Protocol)是一套计算机通过网络进行通信的规则.计算机专家设计出HTTP,使HTTP客 ...
- Java实现数组去除重复数据的方法详解
一.用List集合实现 int[] str = {5, 6, 6, 6, 8, 8, 7,4}; List<Integer> list = new ArrayList<Integer ...
- 013对象—— __clone __toString __call
<?php /** * */ //__clone()方法对一个对象实例进行的浅复制,对象内的基本数值类型进行的是传值复制 /*class a { public $uname; public $n ...
- 获取Activity的返回参数
一.新建一个空的工程 二.在主界面中添加一个按钮和一个TextView组件 三.新建一个空的activity,命名为TheAty,并添加一个按钮和一个EditText组件 四.重写TheAty的源代码 ...
- react pagination
class AppPagination extends React.Component { handleChange(pageNum) { this.props.handleChangePage(pa ...
- redis 内存库设置 教你怎么解决64位Windows版Redis狂占C盘的问题.
http://blog.csdn.net/renfufei/article/details/41180007 # heapdir指定内存映射文件路径名,不能是文件名 # heapdir <dir ...
- 【tensorflow:Google】三、tensorflow入门
[一]计算图模型 节点是计算,边是数据流, a = tf.constant( [1., 2.] )定义的是节点,节点有属性 a.graph 取得默认计算图 g1 = tf.get_default_gr ...