-1
如果我使用數組作爲函數的參數是這樣的:PHP - 如果使用數組作爲函數的參數如何填寫功能陣列參數
function test($arg = array('name'=>'','position'=>'')){
echo $arg['name'];
}
如何時使用此功能填補數組參數?
如果我使用數組作爲函數的參數是這樣的:PHP - 如果使用數組作爲函數的參數如何填寫功能陣列參數
function test($arg = array('name'=>'','position'=>'')){
echo $arg['name'];
}
如何時使用此功能填補數組參數?
當你調用的功能等:
test(array('name'=>'username', 'position'=>'director'));
你有什麼有function test($arg = array('name','position'))
是默認的參數值的方式。一個數組http://php.net/manual/ro/functions.arguments.php
叫它:
你可以閱讀更多關於它在這裏
$name = "Fred";
$position = "President";
test(array('name' => $name, 'position' => $position));