相关疑难解决方法(0)

我的PHP函数应该接受一个参数数组还是应该显式请求参数?

在我正在研究的PHP Web应用程序中,我看到以两种可能的方式定义函数.

方法1:

function myfunc($arg1, $arg2, $arg3)
Run Code Online (Sandbox Code Playgroud)

方法2:

// where $array_params has the structure array('arg1'=>$val1, 'arg2'=>$val2, 'arg3'=>$val3)
function myfunc($array_params)
Run Code Online (Sandbox Code Playgroud)

什么时候应该使用一种方法而不是另一种 似乎如果系统要求不断变化,因此myfunc的参数数量不断变化,方法1可能需要大量维护.

php overloading

37
推荐指数
4
解决办法
3万
查看次数

标签 统计

overloading ×1

php ×1