时间:2021-07-01 10:21:17 帮助过:25人阅读
接口摘要:
Serializable { /* 方法 */ abstract public string serialize ( void ) abstract public mixed unserialize ( string $serialized ) }
例子说明:
<?php /** * 自定义类的序列化操作 * * @author 疯狂老司机 */ class obj implements Serializable { private $data; public function __construct() { $this->data = "My private data"; } public function serialize() { return serialize($this->data); } public function unserialize($data) { $this->data = unserialize($data); } public function getData() { return $this->data; } } $obj = new obj; $ser = serialize($obj); $newobj = unserialize($ser); var_dump($newobj->getData()); ?>
输出:
string 'My private data'
相关推荐:
php—Serializable接口
以上就是PHP之Serializable序列表接口详解的详细内容,更多请关注Gxl网其它相关文章!