php魔术方法:1、【_sleep()】控制对象序列化时真正处理的部分;2、【_wakeup()】在反序列化后还原对象属性;3、【_toString()】对象转换成为字符串的机制。

本教程操作环境:windows7系统、PHP5.6版,DELL G3电脑。
php魔术方法:
_sleep() 可以控制对象序列化时真正处理的部分
_wakeup() 在反序列化后还原对象属性
立即学习“PHP免费学习笔记(深入)”;
_toString() 对象转换成为字符串的机制
随缘网络PHP企业网站管理系统V2.0正式发布,该企业网站管理系统采用PHP+MYSQL编写,界面色调风格延续之前1.0版管理系统简洁浅蓝色风格,稍有所变动。变更分类树形目录方式采用jquery库,产品,文章三级无限分类。希望大家能够喜欢。系统中难免有些小问题,希望大家在使用中有什么问题可到本站论坛提出,我们将总结各问题后给予修正并升级。本站再次声明对于免费版系列系统本站不提供QQ电话等技术咨询服
把php变量转换成一串编码后字符串,方法为serialize() 反序列化unserialize()
//序列化
class testSerialize{
public $a = 10;
public $b = 15;
public $c = 20;
function _construct(){
$this->b = $this->a * 10;
$this->c = $this->b * 2;
}
}
$k = serialize(new testSerialize());
echo $k;//
out: O:13:"testSerialize":3:{s:1:"a";i:10;s:1:"b";i:15;s:1:"c";i:20;}
$j = unserialize($k);
sleep方法:
class testSerialize1{
public $a = 10;
public $b = 15;
public $c = 20;
function _construct(){
$this->b = $this->a * 10;
$this->c = $this->b * 2;
}
function __sleep(){
return $this->a;
}
}
$k = serialize(new testSerialize1());
echo $k;其他方法同理
相关视频推荐:PHP编程从入门到精通










