3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A implements Serializable { 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 = 23, Position 2 = 25
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 41
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
2 jumps found. (Code = 43) Position 1 = 59, Position 2 = 61
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 62
Branch analysis from position: 62
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 61
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
2 jumps found. (Code = 43) Position 1 = 59, Position 2 = 61
Branch analysis from position: 59
Branch analysis from position: 61
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 41
Branch analysis from position: 39
Branch analysis from position: 41
filename:       /in/GjoBg
function name:  (null)
number of ops:  65
compiled vars:  !0 = $oC, !1 = $ser, !2 = $new_oC
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'a'
   25     1        DECLARE_CLASS                                            'b', 'a'
   30     2        DECLARE_CLASS                                            'c', 'a'
   36     3        NEW                                              $3      'C'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $3
   37     6        NEW                                              $7      'A'
          7        DO_FCALL                                      0          
          8        ASSIGN_OBJ                                               !0, 'A'
          9        OP_DATA                                                  $7
   38    10        NEW                                              $10     'B'
         11        DO_FCALL                                      0          
         12        ASSIGN_OBJ                                               !0, 'B'
         13        OP_DATA                                                  $10
   39    14        FETCH_OBJ_R                                      ~14     !0, 'A'
         15        FETCH_OBJ_W                                      $12     !0, 'B'
         16        ASSIGN_OBJ                                               $12, 'A'
         17        OP_DATA                                                  ~14
   41    18        FETCH_OBJ_R                                      ~15     !0, 'A'
         19        FETCH_OBJ_R                                      ~16     !0, 'B'
         20        FETCH_OBJ_R                                      ~17     ~16, 'A'
         21        IS_IDENTICAL                                             ~15, ~17
         22      > JMPZ                                                     ~18, ->25
         23    >   QM_ASSIGN                                        ~19     'yes'
         24      > JMP                                                      ->26
         25    >   QM_ASSIGN                                        ~19     'no'
         26    >   ECHO                                                     ~19
         27        ECHO                                                     '%0A'
   42    28        INIT_FCALL                                               'serialize'
         29        FETCH_OBJ_R                                      ~20     !0, 'A'
         30        SEND_VAL                                                 ~20
         31        DO_ICALL                                         $21     
         32        INIT_FCALL                                               'serialize'
         33        FETCH_OBJ_R                                      ~22     !0, 'B'
         34        FETCH_OBJ_R                                      ~23     ~22, 'A'
         35        SEND_VAL                                                 ~23
         36        DO_ICALL                                         $24     
         37        IS_IDENTICAL                                             $21, $24
         38      > JMPZ                                                     ~25, ->41
         39    >   QM_ASSIGN                                        ~26     'yes'
         40      > JMP                                                      ->42
         41    >   QM_ASSIGN                                        ~26     'no'
         42    >   ECHO                                                     ~26
         43        ECHO                                                     '%0A'
   44    44        INIT_FCALL                                               'serialize'
         45        SEND_VAR                                                 !0
         46        DO_ICALL                                         $27     
         47        ASSIGN                                                   !1, $27
   46    48        ECHO                                                     !1
         49        ECHO                                                     '%0A'
   48    50        INIT_FCALL                                               'unserialize'
         51        SEND_VAR                                                 !1
         52        DO_ICALL                                         $29     
         53        ASSIGN                                                   !2, $29
   50    54        FETCH_OBJ_R                                      ~31     !2, 'A'
         55        FETCH_OBJ_R                                      ~32     !2, 'B'
         56        FETCH_OBJ_R                                      ~33     ~32, 'A'
         57        IS_IDENTICAL                                             ~31, ~33
         58      > JMPZ                                                     ~34, ->61
         59    >   QM_ASSIGN                                        ~35     'yes'
         60      > JMP                                                      ->62
         61    >   QM_ASSIGN                                        ~35     'no'
         62    >   ECHO                                                     ~35
         63        ECHO                                                     '%0A'
         64      > 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/GjoBg
function name:  serialize
number of ops:  14
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
   11     9        INIT_FCALL                                               'serialize'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $9      
         12      > RETURN                                                   $9
   14    13*     > 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/GjoBg
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: [no user functions]
Class C: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.5 ms | 1404 KiB | 17 Q