3v4l.org

run code in 500+ PHP versions simultaneously
<?php class A implements Serializable { function __construct($o) { $this->o =& $o; } function serialize() { return serialize([&$this->o]); } function unserialize($s) { $this->o =& unserialize($s)[0]; } } $o = [new stdClass]; $r = unserialize(serialize([new A($o), new A($o)])); var_dump($r[0]->o[0] === $r[1]->o[0]);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HBuSg
function name:  (null)
number of ops:  31
compiled vars:  !0 = $o, !1 = $r
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   DECLARE_CLASS                                                'a'
   13     1        NEW                                                  $2      'stdClass'
          2        DO_FCALL                                          0          
          3        INIT_ARRAY                                           ~4      $2
          4        ASSIGN                                                       !0, ~4
   14     5        INIT_FCALL                                                   'unserialize'
          6        INIT_FCALL                                                   'serialize'
          7        NEW                                                  $6      'A'
          8        SEND_VAR_EX                                                  !0
          9        DO_FCALL                                          0          
         10        INIT_ARRAY                                           ~8      $6
         11        NEW                                                  $9      'A'
         12        SEND_VAR_EX                                                  !0
         13        DO_FCALL                                          0          
         14        ADD_ARRAY_ELEMENT                                    ~8      $9
         15        SEND_VAL                                                     ~8
         16        DO_ICALL                                             $11     
         17        SEND_VAR                                                     $11
         18        DO_ICALL                                             $12     
         19        ASSIGN                                                       !1, $12
   15    20        INIT_FCALL                                                   'var_dump'
         21        FETCH_DIM_R                                          ~14     !1, 0
         22        FETCH_OBJ_R                                          ~15     ~14, 'o'
         23        FETCH_DIM_R                                          ~16     ~15, 0
         24        FETCH_DIM_R                                          ~17     !1, 1
         25        FETCH_OBJ_R                                          ~18     ~17, 'o'
         26        FETCH_DIM_R                                          ~19     ~18, 0
         27        IS_IDENTICAL                                         ~20     ~16, ~19
         28        SEND_VAL                                                     ~20
         29        DO_ICALL                                                     
         30      > RETURN                                                       1

Class A:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HBuSg
function name:  __construct
number of ops:  4
compiled vars:  !0 = $o
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    4     1        ASSIGN_OBJ_REF                                               'o'
          2        OP_DATA                                                      !0
    5     3      > 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/HBuSg
function name:  serialize
number of ops:  7
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   INIT_FCALL                                                   'serialize'
          1        FETCH_OBJ_W                                          $0      'o'
          2        INIT_ARRAY                                           ~1      $0
          3        SEND_VAL                                                     ~1
          4        DO_ICALL                                             $2      
          5      > RETURN                                                       $2
    8     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/HBuSg
function name:  unserialize
number of ops:  10
compiled vars:  !0 = $s
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    9     0  E >   RECV                                                 !0      
   10     1        INIT_FCALL                                                   'unserialize'
          2        SEND_VAR                                                     !0
          3        DO_ICALL                                             $2      
          4        SEPARATE                                             $2      $2
          5        FETCH_DIM_W                                          $3      $2, 0
          6        MAKE_REF                                             $4      $3
          7        ASSIGN_OBJ_REF                                               'o'
          8        OP_DATA                                                      $4
   11     9      > RETURN                                                       null

End of function unserialize

End of class A.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
176.94 ms | 3370 KiB | 16 Q