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"; $ser = serialize($oC); $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 = 41, Position 2 = 43
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 43
Branch analysis from position: 41
Branch analysis from position: 43
filename:       /in/nUcvW
function name:  (null)
number of ops:  47
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        SEND_VAR                                                 !0
         30        DO_ICALL                                         $20     
         31        ASSIGN                                                   !1, $20
   43    32        INIT_FCALL                                               'unserialize'
         33        SEND_VAR                                                 !1
         34        DO_ICALL                                         $22     
         35        ASSIGN                                                   !2, $22
   44    36        FETCH_OBJ_R                                      ~24     !2, 'A'
         37        FETCH_OBJ_R                                      ~25     !2, 'B'
         38        FETCH_OBJ_R                                      ~26     ~25, 'A'
         39        IS_IDENTICAL                                             ~24, ~26
         40      > JMPZ                                                     ~27, ->43
         41    >   QM_ASSIGN                                        ~28     'yes'
         42      > JMP                                                      ->44
         43    >   QM_ASSIGN                                        ~28     'no'
         44    >   ECHO                                                     ~28
         45        ECHO                                                     '%0A'
         46      > 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/nUcvW
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/nUcvW
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:
195.08 ms | 1404 KiB | 17 Q