3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo implements \Serializable { public $default = 10; public $setMe; private $test = 1; public $removeOnSerialize = 'blah'; public function serialize() { unset($this->removeOnSerialze); return serialize($this->getData()); } public function unserialize($serialized) { foreach (unserialize($serialized) as $key => $value) { $this->$key = $value; } $this->removeOnSerialize = 'Set some value'; } protected function getData() { return (array)$this; } } $obj = new Foo(); $obj->setMe = 9999; print_r($obj); // here I have all as exepcted $serialized = serialize($obj); $unserialized = unserialize($serialized); print_r($unserialized);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mqijs
function name:  (null)
number of ops:  21
compiled vars:  !0 = $obj, !1 = $serialized, !2 = $unserialized
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'foo'
   30     1        NEW                                              $3      'Foo'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
   31     4        ASSIGN_OBJ                                               !0, 'setMe'
          5        OP_DATA                                                  9999
   33     6        INIT_FCALL                                               'print_r'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                                 
   35     9        INIT_FCALL                                               'serialize'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $8      
         12        ASSIGN                                                   !1, $8
   37    13        INIT_FCALL                                               'unserialize'
         14        SEND_VAR                                                 !1
         15        DO_ICALL                                         $10     
         16        ASSIGN                                                   !2, $10
   39    17        INIT_FCALL                                               'print_r'
         18        SEND_VAR                                                 !2
         19        DO_ICALL                                                 
         20      > RETURN                                                   1

Class Foo:
Function serialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mqijs
function name:  serialize
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   UNSET_OBJ                                                'removeOnSerialze'
   13     1        INIT_FCALL                                               'serialize'
          2        INIT_METHOD_CALL                                         'getData'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                         $1      
          6      > RETURN                                                   $1
   14     7*     > RETURN                                                   null

End of function serialize

Function unserialize:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/mqijs
function name:  unserialize
number of ops:  14
compiled vars:  !0 = $serialized, !1 = $value, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   18     1        INIT_FCALL                                               'unserialize'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $3      
          4      > FE_RESET_R                                       $4      $3, ->10
          5    > > FE_FETCH_R                                       ~5      $4, !1, ->10
          6    >   ASSIGN                                                   !2, ~5
   19     7        ASSIGN_OBJ                                               !2
          8        OP_DATA                                                  !1
   18     9      > JMP                                                      ->5
         10    >   FE_FREE                                                  $4
   21    11        ASSIGN_OBJ                                               'removeOnSerialize'
         12        OP_DATA                                                  'Set+some+value'
   22    13      > RETURN                                                   null

End of function unserialize

Function getdata:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mqijs
function name:  getData
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   FETCH_THIS                                       ~0      
          1        CAST                                          7  ~1      ~0
          2      > RETURN                                                   ~1
   27     3*     > RETURN                                                   null

End of function getdata

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.76 ms | 1404 KiB | 19 Q