內建函數 (function) interface_exists() 判斷某個介面 (interface) 是否存在
函數 | 說明 |
---|---|
bool interface_exists(string $interface_name [, bool $autoload = true]) | $interface_name 為介面名稱。 |
參數 (parameter) 為介面名稱,須注意回傳的是布林值。
舉例如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | <?php interface Apple {} if ( interface_exists ( 'Apple' )) { echo "Apple existed.\n" ; } else { echo "Apple didn't exist.\n" ; } if ( interface_exists ( 'Spoon' )) { echo "Spoon existed.\n" ; } else { echo "Spoon didn't exist.\n" ; } /* 《程式語言教學誌》的範例程式 檔名:object12.php 功能:示範 PHP 程式 作者:張凱慶 時間:西元 2013 年 2 月 */ ?> |
執行結果如下

中英文術語對照 | |
---|---|
函數 | function |
陣列 | array |
參數 | parameter |
您可以繼續參考
類別、物件相關函數
相關目錄
回 PHP 快速導覽
回 PHP 教材
回首頁
參考資料
http://www.php.net/manual/en/function.interface-exists.php
沒有留言:
張貼留言