1、对象串行化网络
1.将对象转为字符串(不用看懂)
class Person { var $name; public $arr = array("aaa","bbb","ccc"); function __construct($name){ $this->name=$name; } function say(){ echo $this->name."<br>"; } function __clone(){ $this->name="ni"; } function __call($method,$args){ if(in_array($method,$this->arr)){ echo $args[0]."<br>"; }else{ echo "你调用的方法{$method}()不存在!<br>"; } } }; $p=new Person("wo"); $s=serialize($p); file_put_contents("result.txt",$s); echo "保存成功!";
2.逆向为反串行化 3.将对象在网络中传输时须要串行化 4.将对象持久保存时须要串行化