序列化例子
定义几个类和对象,输出序列化的东西
<?php
class Stu{
public $name;
public $age;
public $sex;
public $score;
}
$stul= new Stu();
$stul->name="hutong";
$stul->age=21;
$stul->sex=114514;
echo "<br \>";
echo serialize($stul);
?>
输出
显示的是已经被序列化的数据
反序列化自动调用计算器
<?php
class Stu{
public $name;
public $age;
public $sex;
public $score;
public function __wakeup(){
if(@$_GET['cmd']=="hutong"){
system('calc');
}
}
}
$stul= new Stu();
$stul->name="hutong";
$stul->age=21;
$stul->sex=114514;
$a=serialize($stul);
@unserialize($a);
?>
访问
无回显
传参
?cmd=hutong