至于
PHP 5.4
你有速记数组语法(没有必要用繁琐的数组来指定数组),而是使用“[]”。
你可以
模仿
命名参数有很多种方法,一种简单有效的方法可能是:
bar('one', ['a1' => 'two', 'bar' => 'three', 'foo' => 'four']);
// output: twothreefour
function bar ($a1, $kwargs = ['bar' => null, 'foo' => null]) {
extract($kwargs);
echo $a1;
echo $bar;
echo $foo;
}