class a {
public function getContinents () {
// connect to db
$res = $this->db->query("SELECT continent FROM mytable");
return $res;
}
}
$obj = new a();
$getContinents = $obj->getContinents();
所以如果我们在这里检查变量 getContinents,它是一个有效的 mysqli-result 对象
var_dump($getContinents);
结果是
object(mysqli_result)#4 (5) { ["current_field"]=> int(0) ["field_count"]=> int(1) ["lengths"]=> NULL ["num_rows"]=> int(6) ["type"]=> int(0) }
现在我想序列化和反序列化这个对象
$getContinents_to_str = serialize($getContinents);
var_dump(unserialize($getContinents_to_str));
现在结果是
Warning: var_dump(): Property access is not allowed yet in ...
object(mysqli_result)#5 (5) { ["current_field"]=> NULL ["field_count"]=> NULL ["lengths"]=> NULL ["num_rows"]=> NULL ["type"]=> NULL }
请告诉我为什么会这样?哪里错了?