在根據不同內容調用方法的時候,個人不太喜歡Switch case調用,嘗試用一下數組裝函數,代碼如下:
<?php
/**
* 數組 存放 函數方法Dome
*/
class test{
function __construct(){
$arr_list = array(
"a"=>$this->d(),
"b"=>$this->c()
);
echo $arr_list["b"]; // 輸出結果 I am c
}
function d(){
return "I am d";
}
function c(){
return "I am c";
}
}
$test = new test();
?>