我記得我在檔案的某個地方讀到過它,并看到它在代碼中被使用,但不記得它的名字。它被描述為“做array_merge()的奇特方式”或其他東西。它允許合并兩個帶有引數的陣列,并包括一些簡單的型別檢查。
function doSomething ($params) {
$defaultParams = [
'foo' => false,
'bar' => 1,
];
$p = whatsTheFunctionName($params, $defaultParams, [/* foo is bool, bar is int */]);
}
uj5u.com熱心網友回復:
我認為您正在尋找 OptionsResolver 組件:“array_replace PHP 函式的改進替換”。
請參閱:https ://symfony.com/doc/current/components/options_resolver.html
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/513431.html
標籤:交响乐
