3v4l.org

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

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/J6g8e
function name:  __construct
number of ops:  4
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        ASSIGN_OBJ                                               'obj'
          2        OP_DATA                                                  !0
    8     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/J6g8e
function name:  serialize
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   INIT_FCALL                                               'serialize'
          1        FETCH_OBJ_R                                      ~0      'obj'
          2        INIT_ARRAY                                       ~1      ~0, 'obj'
          3        SEND_VAL                                                 ~1
          4        DO_ICALL                                         $2      
          5      > RETURN                                                   $2
   12     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/J6g8e
function name:  unserialize
number of ops:  9
compiled vars:  !0 = $s, !1 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1        INIT_FCALL                                               'unserialize'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $2      
          4        ASSIGN                                                   !1, $2
   16     5        FETCH_DIM_R                                      ~5      !1, 'obj'
          6        ASSIGN_OBJ                                               'obj'
          7        OP_DATA                                                  ~5
   17     8      > RETURN                                                   null

End of function unserialize

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.4 ms | 1405 KiB | 19 Q