class Layoutdemo{ function index(){
$db = new Db();
$id=390;
$layout_json = array();
if($info = $db->find("SELECT * FROM `hotel_layout` WHERE `id`='" . $id . "'")){
$layout_json['name']= $info['name'];
}
$redis = new Redis();
$redis->connect(REDIS_HOST,REDIS_PORT); #变量需要提前require_once进来
$redis->auth(REDIS_AUTH);
//$redisinfo = $redis->get('layout_'.$id);
$layout_json['redis_data'] = $this->htmlStr(gzuncompress($redis->get('layout_'.$id)));
echo json_encode($layout_json);
}
public function htmlStr($data){
$data = str_replace('<','<',$data);
$data = str_replace('>','>',$data);
$data = str_replace('∼','~',$data);
$data = str_replace('"','"',$data);
$data = str_replace('…','…',$data);
$data = str_replace('&','&',$data);
return $data;
}
}
$a = new Layoutdemo();
$a->index();