//定义一个用来序列化对象的函数 function my_serialize( $obj ) { return base64_encode(gzcompress(serialize($obj))); } //反序列化 function my_unserialize($txt) { return unserialize(gzuncompress(base64_decode($txt))); }