get_parent_class ( $object );
它检索对象或类的父类名称。
Sr.No | Parameter & Description |
---|---|
1 |
object(必需) 对象或类名。 链接:https://www.learnfk.comhttps://www.learnfk.com/php/php-function-get-parent-class.html 来源:LearnFk无涯教程网 |
它返回当前脚本中已声明类的名称的数组。
<?php class f1 { function f1() { //implements some logic } } class child extends f1 { function child() { echo "I'm " , get_parent_class($this) , "'s son\n"; } } class child2 extends f1 { function child2() { echo "I'm " , get_parent_class('child2') , "'s son too\n"; } } $foo=new child(); $bar=new child2(); ?>
它将产生以下输出-
I'm f1's son I'm f1's son too
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)