Class Layoutdemo{function Index () {$db = new db (), $id =390, $layout _json = Array (), if ($info = $db->find ("select * from ' Ho Tel_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 ();
PHP Connection Redis Query data