验证中...
开源中国 2018 年度最后一场技术盛会邀你来约~错过就要等明年啦!点此立即预约
serialize()
Raw Copy
//创建一个person类
class person {
public $name;
public $gender;
public function say() {
echo $this->name, " is ", $this->gender;
}
}
// 创建学生对象
$student = new person();
$student->name='Tom';
$student->gender='male';
// 序列化对象, 写入文件
$str = serialize($student);
file_put_contents('store.txt', $str);
//引入类文件,反序列化方法
include "index.php";
$str = file_get_contents('store.txt');
$student = unserialize($str);
$student->say();

Comment list( 0 )

You need to Sign in for post a comment

Help Search

12_float_left_people 12_float_left_close