3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Widget implements Serializable { public $references = array(); public function serialize() { $vars = get_object_vars($this); $serialized = serialize($vars); return $serialized; } public function unserialize($serialized) { $array = unserialize($serialized); foreach($array as $k => $v) $this->$k = $v; } } class Placeholder { public $id; public function __construct($id) { $this->id = $id; } } $placeholder1 = new Placeholder(1); $placeholder2 = new Placeholder(2); $widgets = array(new Widget, new Widget, new Widget, new Widget); $widgets[0]->references[] = $placeholder1; $widgets[1]->references[] = $placeholder2; $widgets[2]->references[] = $placeholder1; $widgets[3]->references[] = $placeholder1; $serialized = serialize($widgets); var_dump($serialized); var_dump(unserialize($serialized));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/X6iEt
function name:  (null)
number of ops:  52
compiled vars:  !0 = $placeholder1, !1 = $placeholder2, !2 = $widgets, !3 = $serialized
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   DECLARE_CLASS                                            'widget'
   34     1        NEW                                              $4      'Placeholder'
          2        SEND_VAL_EX                                              1
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $4
   35     5        NEW                                              $7      'Placeholder'
          6        SEND_VAL_EX                                              2
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !1, $7
   37     9        NEW                                              $10     'Widget'
         10        DO_FCALL                                      0          
         11        INIT_ARRAY                                       ~12     $10
         12        NEW                                              $13     'Widget'
         13        DO_FCALL                                      0          
         14        ADD_ARRAY_ELEMENT                                ~12     $13
         15        NEW                                              $15     'Widget'
         16        DO_FCALL                                      0          
         17        ADD_ARRAY_ELEMENT                                ~12     $15
         18        NEW                                              $17     'Widget'
         19        DO_FCALL                                      0          
         20        ADD_ARRAY_ELEMENT                                ~12     $17
         21        ASSIGN                                                   !2, ~12
   39    22        FETCH_DIM_W                                      $20     !2, 0
         23        FETCH_OBJ_W                                      $21     $20, 'references'
         24        ASSIGN_DIM                                               $21
         25        OP_DATA                                                  !0
   40    26        FETCH_DIM_W                                      $23     !2, 1
         27        FETCH_OBJ_W                                      $24     $23, 'references'
         28        ASSIGN_DIM                                               $24
         29        OP_DATA                                                  !1
   41    30        FETCH_DIM_W                                      $26     !2, 2
         31        FETCH_OBJ_W                                      $27     $26, 'references'
         32        ASSIGN_DIM                                               $27
         33        OP_DATA                                                  !0
   42    34        FETCH_DIM_W                                      $29     !2, 3
         35        FETCH_OBJ_W                                      $30     $29, 'references'
         36        ASSIGN_DIM                                               $30
         37        OP_DATA                                                  !0
   44    38        INIT_FCALL                                               'serialize'
         39        SEND_VAR                                                 !2
         40        DO_ICALL                                         $32     
         41        ASSIGN                                                   !3, $32
   45    42        INIT_FCALL                                               'var_dump'
         43        SEND_VAR                                                 !3
         44        DO_ICALL                                                 
   46    45        INIT_FCALL                                               'var_dump'
         46        INIT_FCALL                                               'unserialize'
         47        SEND_VAR                                                 !3
         48        DO_ICALL                                         $35     
         49        SEND_VAR                                                 $35
         50        DO_ICALL                                                 
         51      > RETURN                                                   1

Class Widget:
Function serialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/X6iEt
function name:  serialize
number of ops:  11
compiled vars:  !0 = $vars, !1 = $serialized
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   INIT_FCALL                                               'get_object_vars'
          1        FETCH_THIS                                       ~2      
          2        SEND_VAL                                                 ~2
          3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !0, $3
   10     5        INIT_FCALL                                               'serialize'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $5      
          8        ASSIGN                                                   !1, $5
   12     9      > RETURN                                                   !1
   13    10*     > RETURN                                                   null

End of function serialize

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

End of function unserialize

End of class Widget.

Class Placeholder:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/X6iEt
function name:  __construct
number of ops:  4
compiled vars:  !0 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
   30     1        ASSIGN_OBJ                                               'id'
          2        OP_DATA                                                  !0
   31     3      > RETURN                                                   null

End of function __construct

End of class Placeholder.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.79 ms | 1396 KiB | 21 Q