//sleep,wakeup
echo '<br>';
class Aaa{
public $a1=1;
public $a2=2;
protected $a3=3;
protected $a4=4;
private $a5=5;
private $a6=6;
public function __sleep(){
return ['a1','a3','a5'];
}
public function __wakeup(){
$this->a1=11;
$this->a3=33;
}
}
$aaa=new Aaa();
file_put_contents('aaa.txt', serialize($aaa));
$str1=file_get_contents('aaa.txt');
$ooo=unserialize($str1);
var_dump($ooo);
echo '<br>';
//异常类//
class Test{
public function sum(int $a,int $b){
$sum=$a+$b;
}
}
try{
$test=new Test();
$result=$test->sum(1,'abc');
echo $result;
}catch (Exception $f){
echo $f->getMessage();
}