【发布时间】:2011-05-15 08:41:06
【问题描述】:
我有一个看起来像这样的函数:
function test($arg1 = 'my_value', $arg2 = 'second')
{
}
当我调用它时,我只想将第二个值设置为不同的值,如下所示:
test(inherit, 'changed value');
我发现可以将此行添加到我的函数中(当我的“继承”更改为空时):
$arg1 = ( is_null( $arg1 ) ? 'my_value' : $arg1 );
有没有更好的方法,更好的方法来解决它?
【问题讨论】:
-
你的问题有答案
标签: php function default inheritance