$searchActionArr = [
'1' => 'searchAlbumList',
'2' => 'searchUser',
'3' => 'searchActivityList',
];
if(filled($searchActionArr[$searchType]) && method_exists($this,$searchActionArr[$searchType])){
$instanceMethod = $searchActionArr[$searchType];
$result = $this->$instanceMethod($searchName);
result = $this->{$searchActionArr[$searchType]}($searchName);
}
或 使用“{}”,参考在php中{}的作用
if(filled($searchActionArr[$searchType]) && method_exists($this,$searchActionArr[$searchType])){
result = $this->{$searchActionArr[$searchType]}($searchName);
}
标签:instanceMethod,调用,searchType,searchName,searchActionArr,result,php,动态 From: https://www.cnblogs.com/chihuobao/p/16896829.html