douqiju2520 2009-09-14 02:03
浏览 86
已采纳

是否可以将PHP函数的参数列表转换为数组?

Suppose I have a function:

function my_function($a, $b, $c) {
    ...
}

I want to be able to play with my parameter list as if it were an array - as with here, using a fake $parameter_list variable:

function my_function($a, $b, $c) {
    foreach ($parameter_list as $value) {
        print $value."
";
    }
    ...
}

How can I do this?

  • 写回答

1条回答 默认 最新

  • doufei9805 2009-09-14 02:05
    关注

    Just call func_get_args().

    It's normally used for user-defined functions that have a variable number of arguments but there's no reason you can't use it for a "normal" function.

    This returns a numerically-indexed array of function arguments. There is no way of returning the parameter names.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 一道python难题
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度