以下是如何反序列化多个属性的示例
class Example implements \Serializable
{
protected $property1;
protected $property2;
protected $property3;
public function __construct($property1, $property2, $property3)
{
$this->property1 = $property1;
$this->property2 = $property2;
$this->property3 = $property3;
}
public function serialize()
{
return serialize([
$this->property1,
$this->property2,
$this->property3,
]);
}
public function unserialize($data)
{
list(
$this->property1,
$this->property2,
$this->property3
) = unserialize($data);
}
}