![]() |
|
首页 │ Apache │ Linux│ Java│ MySQL│ 注册│帮助 | |||
相关问题
<?php
// classa.inc:
class A
{
var $one = 1;
function show_one()
{
echo $this->one;
}
}
// page1.php:
include("classa.inc");
$a = new A;
$s = serialize($a);
// 将 $s 存放在某处使 page2.php 能够找到
$fp = fopen("store", "w");
fputs($fp, $s);
fclose($fp);
// page2.php:
// 为了正常解序列化需要这一行
include("classa.inc");
$s = implode("", @file("store"));
$a = unserialize($s);
// 现在可以用 $a 对象的 show_one() 函数了
$a->show_one();
?>
我想知道的是,为什么会有这么一种用法呢?实际应用中,此用法有什么实际意义吗?
提问者:NUG 08-15 15:03
答复

