我正在尝试调用函数参数并将其分配给变量。 该函数将信息作为数组获取
function info($name,$email,$number){
}
//calling the function parameter $number from function
$exten = call_user_func_array(info,$number);
答案 0 :(得分:0)
如果$number
是可调用的,那么您可以将其称为$number()
答案 1 :(得分:0)
我认为你误解了这些概念,所以我认为这就是你想要的:
function info($needed){
$name = "john";
$email = "john@doe.com";
$number = "555-5555";
switch($needed) {
case "name":
return $name;
break;
case "email":
return $email;
break;
case "number":
return $number;
break;
default:
return null;
}
}
//calling the function parameter $number from function
echo call_user_func("info","number");