3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public function serialize () { $serialized = array(); foreach($this as $prop => $val) { $serialized[$prop] = $val; } //return serialize($serialized); return serialize(get_object_vars($this)); } function unserialize($serialized) { foreach(unserialize($serialized) as $prop => $val) { $this->$prop = $val; } return true; } } class B extends A { public $A; } class C extends A { public $A; public $B; } $oC = new C(); $oC->A = new A(); $oC->B = new B(); $oC->B->A = $oC->A; echo $oC->A === $oC->B->A ? "yes" : "no", "\n"; echo serialize($oC->A) === serialize($oC->B->A) ? 'yes' : 'no', "\n"; $ser = serialize($oC); echo $ser, "\n"; $new_oC = unserialize($ser); echo $new_oC->A === $new_oC->B->A ? "yes" : "no", "\n";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 38
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 56, Position 2 = 58
Branch analysis from position: 56
1 jumps found. (Code = 42) Position 1 = 59
Branch analysis from position: 59
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 58
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
2 jumps found. (Code = 43) Position 1 = 56, Position 2 = 58
Branch analysis from position: 56
Branch analysis from position: 58
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 38
Branch analysis from position: 36
Branch analysis from position: 38
filename:       /in/UZBYN
function name:  (null)
number of ops:  62
compiled vars:  !0 = $oC, !1 = $ser, !2 = $new_oC
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   NEW                                              $3      'C'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   37     3        NEW                                              $7      'A'
          4        DO_FCALL                                      0          
          5        ASSIGN_OBJ                                               !0, 'A'
          6        OP_DATA                                                  $7
   38     7        NEW                                              $10     'B'
          8        DO_FCALL                                      0          
          9        ASSIGN_OBJ                                               !0, 'B'
         10        OP_DATA                                                  $10
   39    11        FETCH_OBJ_R                                      ~14     !0, 'A'
         12        FETCH_OBJ_W                                      $12     !0, 'B'
         13        ASSIGN_OBJ                                               $12, 'A'
         14        OP_DATA                                                  ~14
   41    15        FETCH_OBJ_R                                      ~15     !0, 'A'
         16        FETCH_OBJ_R                                      ~16     !0, 'B'
         17        FETCH_OBJ_R                                      ~17     ~16, 'A'
         18        IS_IDENTICAL                                             ~15, ~17
         19      > JMPZ                                                     ~18, ->22
         20    >   QM_ASSIGN                                        ~19     'yes'
         21      > JMP                                                      ->23
         22    >   QM_ASSIGN                                        ~19     'no'
         23    >   ECHO                                                     ~19
         24        ECHO                                                     '%0A'
   42    25        INIT_FCALL                                               'serialize'
         26        FETCH_OBJ_R                                      ~20     !0, 'A'
         27        SEND_VAL                                                 ~20
         28        DO_ICALL                                         $21     
         29        INIT_FCALL                                               'serialize'
         30        FETCH_OBJ_R                                      ~22     !0, 'B'
         31        FETCH_OBJ_R                                      ~23     ~22, 'A'
         32        SEND_VAL                                                 ~23
         33        DO_ICALL                                         $24     
         34        IS_IDENTICAL                                             $21, $24
         35      > JMPZ                                                     ~25, ->38
         36    >   QM_ASSIGN                                        ~26     'yes'
         37      > JMP                                                      ->39
         38    >   QM_ASSIGN                                        ~26     'no'
         39    >   ECHO                                                     ~26
         40        ECHO                                                     '%0A'
   44    41        INIT_FCALL                                               'serialize'
         42        SEND_VAR                                                 !0
         43        DO_ICALL                                         $27     
         44        ASSIGN                                                   !1, $27
   46    45        ECHO                                                     !1
         46        ECHO                                                     '%0A'
   48    47        INIT_FCALL                                               'unserialize'
         48        SEND_VAR                                                 !1
         49        DO_ICALL                                         $29     
         50        ASSIGN                                                   !2, $29
   50    51        FETCH_OBJ_R                                      ~31     !2, 'A'
         52        FETCH_OBJ_R                                      ~32     !2, 'B'
         53        FETCH_OBJ_R                                      ~33     ~32, 'A'
         54        IS_IDENTICAL                                             ~31, ~33
         55      > JMPZ                                                     ~34, ->58
         56    >   QM_ASSIGN                                        ~35     'yes'
         57      > JMP                                                      ->59
         58    >   QM_ASSIGN                                        ~35     'no'
         59    >   ECHO                                                     ~35
         60        ECHO                                                     '%0A'
         61      > RETURN                                                   1

Class A:
Function serialize:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 8
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/UZBYN
function name:  serialize
number of ops:  18
compiled vars:  !0 = $serialized, !1 = $val, !2 = $prop
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   ASSIGN                                                   !0, <array>
    8     1        FETCH_THIS                                       ~4      
          2      > FE_RESET_R                                       $5      ~4, ->8
          3    > > FE_FETCH_R                                       ~6      $5, !1, ->8
          4    >   ASSIGN                                                   !2, ~6
    9     5        ASSIGN_DIM                                               !0, !2
          6        OP_DATA                                                  !1
    8     7      > JMP                                                      ->3
          8    >   FE_FREE                                                  $5
   13     9        INIT_FCALL                                               'serialize'
         10        INIT_FCALL                                               'get_object_vars'
         11        FETCH_THIS                                       ~9      
         12        SEND_VAL                                                 ~9
         13        DO_ICALL                                         $10     
         14        SEND_VAR                                                 $10
         15        DO_ICALL                                         $11     
         16      > RETURN                                                   $11
   14    17*     > 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/UZBYN
function name:  unserialize
number of ops:  13
compiled vars:  !0 = $serialized, !1 = $val, !2 = $prop
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      > RETURN                                                   <true>
   22    12*     > RETURN                                                   null

End of function unserialize

End of class A.

Class B:
Function serialize:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 8
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/UZBYN
function name:  serialize
number of ops:  18
compiled vars:  !0 = $serialized, !1 = $val, !2 = $prop
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   ASSIGN                                                   !0, <array>
    8     1        FETCH_THIS                                       ~4      
          2      > FE_RESET_R                                       $5      ~4, ->8
          3    > > FE_FETCH_R                                       ~6      $5, !1, ->8
          4    >   ASSIGN                                                   !2, ~6
    9     5        ASSIGN_DIM                                               !0, !2
          6        OP_DATA                                                  !1
    8     7      > JMP                                                      ->3
          8    >   FE_FREE                                                  $5
   13     9        INIT_FCALL                                               'serialize'
         10        INIT_FCALL                                               'get_object_vars'
         11        FETCH_THIS                                       ~9      
         12        SEND_VAL                                                 ~9
         13        DO_ICALL                                         $10     
         14        SEND_VAR                                                 $10
         15        DO_ICALL                                         $11     
         16      > RETURN                                                   $11
   14    17*     > 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/UZBYN
function name:  unserialize
number of ops:  13
compiled vars:  !0 = $serialized, !1 = $val, !2 = $prop
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      > RETURN                                                   <true>
   22    12*     > RETURN                                                   null

End of function unserialize

End of class B.

Class C:
Function serialize:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 8
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/UZBYN
function name:  serialize
number of ops:  18
compiled vars:  !0 = $serialized, !1 = $val, !2 = $prop
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   ASSIGN                                                   !0, <array>
    8     1        FETCH_THIS                                       ~4      
          2      > FE_RESET_R                                       $5      ~4, ->8
          3    > > FE_FETCH_R                                       ~6      $5, !1, ->8
          4    >   ASSIGN                                                   !2, ~6
    9     5        ASSIGN_DIM                                               !0, !2
          6        OP_DATA                                                  !1
    8     7      > JMP                                                      ->3
          8    >   FE_FREE                                                  $5
   13     9        INIT_FCALL                                               'serialize'
         10        INIT_FCALL                                               'get_object_vars'
         11        FETCH_THIS                                       ~9      
         12        SEND_VAL                                                 ~9
         13        DO_ICALL                                         $10     
         14        SEND_VAR                                                 $10
         15        DO_ICALL                                         $11     
         16      > RETURN                                                   $11
   14    17*     > 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/UZBYN
function name:  unserialize
number of ops:  13
compiled vars:  !0 = $serialized, !1 = $val, !2 = $prop
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      > RETURN                                                   <true>
   22    12*     > RETURN                                                   null

End of function unserialize

End of class C.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.48 ms | 1404 KiB | 19 Q