LazyArrayObject(智能数组对象)

优质
小牛编辑
136浏览
2023-12-01

同时可以作为数组和对象访问的类

// $object = new \Imi\Util\LazyArrayObject;
$object = new \Imi\Util\LazyArrayObject([
    'id'    =>  123,
    'name'  =>  'imi',
]);

$object['id'] = 111;
echo 'id:', $object->id, PHP_EOL;

$object->id = 222;
echo 'id:', $object['id'], PHP_EOL;

$arrayData = $object->toArray();
var_dump($arrayData);