class Dog
{
	public  $id;
	public $name;
}

$dog = new Dog();
$dog->id = 10;
$dog->name = '旺财';

//写入
file_put_contents('E://dog.bin',serialize($dog));

//读取
$file = file_get_contents('E://dog.bin');
$dogObj = unserialize($file); 
echo 'Dog对象信息:id:'.$dogObj->id.',name:'.$dogObj->name;

输出:

Dog对象信息:id:10,name:旺财

你可能感兴趣的文章