get_parent_class() 檢索對象或類的父類名稱。
用法
get_parent_class(object)
參數
object - 測試對象或類的名稱。
返回
get_parent_class() 函數返回類的父類的名稱。
示例
以下是一個例子 -
<?php
class Demo {
function Demo() {
}
}
class Demo2 extends Demo {
function Demo2() {
echo "I'm " , get_parent_class($this) , "'s son \n";
}
}
class Demo3 extends Demo {
function Demo3() {
echo "I'm " , get_parent_class('Demo2') , "'s son too \n";
}
}
$one = new Demo2();
$two = new Demo3();
?>
輸出
I'm Demo's son I'm Demo's son too
相關用法
- PHP get_resource_type()用法及代碼示例
- PHP get_class()用法及代碼示例
- PHP get_declared_interfaces()用法及代碼示例
- PHP get_resource_id()用法及代碼示例
- PHP get_class_methods()用法及代碼示例
- PHP get_headers()用法及代碼示例
- PHP get_class_vars()用法及代碼示例
- PHP get_object_vars()用法及代碼示例
- PHP get_browser()用法及代碼示例
- PHP get_html_translation_table()用法及代碼示例
- PHP get_defined_vars()用法及代碼示例
- PHP get_called_class()用法及代碼示例
- PHP get_declared_classes()用法及代碼示例
- PHP get_meta_tags()用法及代碼示例
- PHP getimagesizefromstring()用法及代碼示例
- PHP getservbyport()用法及代碼示例
- PHP gethostnamel()用法及代碼示例
- PHP getcwd()用法及代碼示例
- PHP getcwd( )用法及代碼示例
- PHP getrandmax()用法及代碼示例
注:本文由純淨天空篩選整理自Ankith Reddy大神的英文原創作品 get_parent_class() function in PHP。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。