Class yii\helpers\ReplaceArrayValue
繼承 | yii\helpers\ReplaceArrayValue |
---|---|
自版本起可用 | 2.0.10 |
原始碼 | https://github.com/yiisoft/yii2/blob/master/framework/helpers/ReplaceArrayValue.php |
代表執行 yii\helpers\ArrayHelper::merge() 時陣列值替換的物件。
使用範例
$array1 = [
'ids' => [
1,
],
'validDomains' => [
'example.com',
'www.example.com',
],
];
$array2 = [
'ids' => [
2,
],
'validDomains' => new \yii\helpers\ReplaceArrayValue([
'yiiframework.com',
'www.yiiframework.com',
]),
];
$result = \yii\helpers\ArrayHelper::merge($array1, $array2);
結果將會是
[
'ids' => [
1,
2,
],
'validDomains' => [
'yiiframework.com',
'www.yiiframework.com',
],
]
公開方法
方法 | 描述 | 定義於 |
---|---|---|
__construct() | 建構子。 | yii\helpers\ReplaceArrayValue |
__set_state() | 在使用 var_export() 後還原類別狀態。 |
yii\helpers\ReplaceArrayValue |
屬性詳細資訊
方法詳細資訊
建構子。
public void __construct ( $value ) | ||
$value | 混合 |
用作替換的值。 |
public function __construct($value)
{
$this->value = $value;
}
在使用 var_export()
後還原類別狀態。
另請參閱 https://php.dev.org.tw/manual/en/function.var-export.php。
public static yii\helpers\ReplaceArrayValue __set_state ( $state ) | ||
$state | 陣列 | |
拋出 | yii\base\InvalidConfigException |
當 $state 屬性不包含 |
---|
public static function __set_state($state)
{
if (!isset($state['value'])) {
throw new InvalidConfigException('Failed to instantiate class "ReplaceArrayValue". Required parameter "value" is missing');
}
return new self($state['value']);
}
註冊 或 登入 以進行評論。