Blogger Information
Blog 17
fans 0
comment 0
visits 12604
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
对象序列化与实战案例
越努力越幸运
Original
481 people have browsed it

//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();

}



Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post