在根据不同内容调用方法的时候,个人不太喜欢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();
?>