3v4l.org

run code in 500+ PHP versions simultaneously
<?php class A { public $a = array(); public function __construct() { $this->a[] = new B(1); $this->a[] = new B(2); } } class B implements Serializable { public $b; public function __construct($c) { $this->b = new C($c); } public function serialize() { return serialize(clone $this->b); } public function unserialize($data) { $this->b = unserialize($data); } } class C { public $c; public function __construct($c) { $this->c = $c; } } $a = unserialize(serialize(new A())); print $a->a[0]->b->c . "\n"; print $a->a[1]->b->c . "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DR8T3
function name:  (null)
number of ops:  23
compiled vars:  !0 = $a
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   DECLARE_CLASS                                                'b'
   44     1        INIT_FCALL                                                   'unserialize'
          2        INIT_FCALL                                                   'serialize'
          3        NEW                                                  $1      'A'
          4        DO_FCALL                                          0          
          5        SEND_VAR                                                     $1
          6        DO_ICALL                                             $3      
          7        SEND_VAR                                                     $3
          8        DO_ICALL                                             $4      
          9        ASSIGN                                                       !0, $4
   46    10        FETCH_OBJ_R                                          ~6      !0, 'a'
         11        FETCH_DIM_R                                          ~7      ~6, 0
         12        FETCH_OBJ_R                                          ~8      ~7, 'b'
         13        FETCH_OBJ_R                                          ~9      ~8, 'c'
         14        CONCAT                                               ~10     ~9, '%0A'
         15        ECHO                                                         ~10
   47    16        FETCH_OBJ_R                                          ~11     !0, 'a'
         17        FETCH_DIM_R                                          ~12     ~11, 1
         18        FETCH_OBJ_R                                          ~13     ~12, 'b'
         19        FETCH_OBJ_R                                          ~14     ~13, 'c'
         20        CONCAT                                               ~15     ~14, '%0A'
         21        ECHO                                                         ~15
         22      > RETURN                                                       1

Class A:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DR8T3
function name:  __construct
number of ops:  13
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    9     0  E >   NEW                                                  $2      'B'
          1        SEND_VAL_EX                                                  1
          2        DO_FCALL                                          0          
          3        FETCH_OBJ_W                                          $0      'a'
          4        ASSIGN_DIM                                                   $0
          5        OP_DATA                                                      $2
   10     6        NEW                                                  $6      'B'
          7        SEND_VAL_EX                                                  2
          8        DO_FCALL                                          0          
          9        FETCH_OBJ_W                                          $4      'a'
         10        ASSIGN_DIM                                                   $4
         11        OP_DATA                                                      $6
   11    12      > RETURN                                                       null

End of function __construct

End of class A.

Class B:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DR8T3
function name:  __construct
number of ops:  7
compiled vars:  !0 = $c
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E >   RECV                                                 !0      
   20     1        NEW                                                  $2      'C'
          2        SEND_VAR_EX                                                  !0
          3        DO_FCALL                                          0          
          4        ASSIGN_OBJ                                                   'b'
          5        OP_DATA                                                      $2
   21     6      > RETURN                                                       null

End of function __construct

Function serialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DR8T3
function name:  serialize
number of ops:  7
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   25     0  E >   INIT_FCALL                                                   'serialize'
          1        FETCH_OBJ_R                                          ~0      'b'
          2        CLONE                                                ~1      ~0
          3        SEND_VAL                                                     ~1
          4        DO_ICALL                                             $2      
          5      > RETURN                                                       $2
   26     6*     > RETURN                                                       null

End of function serialize

Function unserialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DR8T3
function name:  unserialize
number of ops:  7
compiled vars:  !0 = $data
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   28     0  E >   RECV                                                 !0      
   30     1        INIT_FCALL                                                   'unserialize'
          2        SEND_VAR                                                     !0
          3        DO_ICALL                                             $2      
          4        ASSIGN_OBJ                                                   'b'
          5        OP_DATA                                                      $2
   31     6      > RETURN                                                       null

End of function unserialize

End of class B.

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

End of function __construct

End of class C.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
168.44 ms | 2936 KiB | 15 Q