| 函數 | 說明 |
|---|---|
| bool trait_exists(string $traitname [, bool $autoload]) | $traitname 為特徵類別名稱。 |
參數 (parameter) 為特徵類別名稱,須注意回傳的是布林值。
舉例如下
<?php
trait Apple {};
if (trait_exists('Apple')) {
echo "Apple existed.\n";
}
else {
echo "Apple didn't exist.\n";
}
if (trait_exists('Spoon')) {
echo "Spoon existed.\n";
}
else {
echo "Spoon didn't exist.\n";
}
/* 《程式語言教學誌》的範例程式
http://pydoing.blogspot.com/
檔名:object17.php
功能:示範 PHP 程式
作者:張凱慶
時間:西元 2013 年 2 月 */
?>執行結果如下

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