php设计模式-适配器
2021-01-17 08:12
标签:adapter function cti json 数据 get parent ext print php设计模式-适配器 标签:adapter function cti json 数据 get parent ext print 原文地址:https://www.cnblogs.com/xiangdongsheng/p/13369609.html// 数据源类
class Weather
{
public static function getWether()
{
$data = array(
‘tep‘ => 28,
‘wind‘ => 5,
‘sun‘ => ‘sunny‘
);
return serialize($data);
}
}
// 适配不同客户端
class Adapter extends Weather
{
public static function getWether()
{
return $data = json_encode(unserialize(parent::getWether()));
}
}
echo ‘
‘;
print_r(Adapter::getWether());