<?php
class person
{
private $name;
private $sex;
private $age;
function __construct($name="张三",$sex="",$age=90)
{
$this->name=$name;
$this->sex=$sex;
$this->age=$age;
}
function say()
{
echo"这个人在说话<br>";
}
function run()
{
echo"这个人在走路<br>";
}
function __clone()
{
$this->name="我是".$this->name."副本";
$this->age=20;
}
function info()
{
echo"我的名字是:".$this->name." 性别:".$this->sex." 年龄:".$this->age."<br>";
}
function __sleep()
{
$ar=array("name","age");
return $ar;
}
function __wakeup(){
$this->age=90;
}
function __call($na,$ar)
{
echo"你所调用的函数".$na."(参数";
print_r($ar);
echo")不存在<br>";
}
function __destruct()
{
echo"再见".$this->name."<br>";
}
}
$te=new person("张三",'男',50);
/*$rea=serialize($te);
file_put_contents("G:file.txt",$rea);*/
/*$st=file_get_contents("G:file.txt");
$per=unserialize($st);
$per->info();*/
$str=serialize($te);
echo$str."<br>";
$person2=unserialize($str);
$person2->info();
?>
对象的串行化
最新推荐文章于 2020-04-29 17:07:09 发布