用法
get_parent_class ( $object );
定義和用法
它檢索對象或類的父類名稱。
參數
Sr.No | 參數及說明 |
---|---|
1 |
object(Required) 被測試的對象或類名。 |
返回值
它返回當前腳本中已聲明類的名稱的數組。
示例
下麵是這個函數的用法~
<?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
相關用法
- PHP get_parent_class()用法及代碼示例
- 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 - Function get_parent_class()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。