class BaseStruct
{
public function __construct(Array $array = [])
{
foreach ($array as $key => $val) {
if (property_exists(static::class, $key)) { // 如果有存在与key同名的属性,对应赋值
$this->{$key} = $val;
}
}
}
}
网友评论