Php writing a function with unknown parameters?

后端 未结 4 1686
终归单人心
终归单人心 2020-12-20 17:07

How would I go about writing a function in php with an unknown number of parameters, for example

function echoData (parameter1, parameter2,) {
    //do somet         


        
4条回答
  •  礼貌的吻别
    2020-12-20 17:43

    use func_get_args() to retrieve an array of all parameters like that:

    $args = func_get_args();
    

    You can then use the array or iterate over it, whatever suits your use-case best.

提交回复
热议问题