3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Bar {} class Foo implements Serializable { public $test; public function __construct($test) { $this->test = $test; } public function serialize() { return $this->test; } public function unserialize($serialized) { //the following line causes problems unserialize('O:3:"Bar":1:{s:4:"bar1";O:3:"Bar":0:{}}'); $this->test = $serialized; } } $foo1 = new Foo('foo1'); $foo2 = new Foo('foo2'); $foo3 = new Foo('foo3'); $ar = array( array( 'instance' => $foo1, ), array( 'instance' => $foo2, ), array( 'instance' => $foo3, 'parent' => $foo2 ) ); $ar = serialize($ar); $ar = unserialize($ar); print_r($ar);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oAhZZ
function name:  (null)
number of ops:  33
compiled vars:  !0 = $foo1, !1 = $foo2, !2 = $foo3, !3 = $ar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'foo'
   17     1        NEW                                              $4      'Foo'
          2        SEND_VAL_EX                                              'foo1'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $4
   18     5        NEW                                              $7      'Foo'
          6        SEND_VAL_EX                                              'foo2'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !1, $7
   19     9        NEW                                              $10     'Foo'
         10        SEND_VAL_EX                                              'foo3'
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !2, $10
   22    13        INIT_ARRAY                                       ~13     !0, 'instance'
         14        INIT_ARRAY                                       ~14     ~13
   25    15        INIT_ARRAY                                       ~15     !1, 'instance'
         16        ADD_ARRAY_ELEMENT                                ~14     ~15
   28    17        INIT_ARRAY                                       ~16     !2, 'instance'
   29    18        ADD_ARRAY_ELEMENT                                ~16     !1, 'parent'
         19        ADD_ARRAY_ELEMENT                                ~14     ~16
   20    20        ASSIGN                                                   !3, ~14
   32    21        INIT_FCALL                                               'serialize'
         22        SEND_VAR                                                 !3
         23        DO_ICALL                                         $18     
         24        ASSIGN                                                   !3, $18
   33    25        INIT_FCALL                                               'unserialize'
         26        SEND_VAR                                                 !3
         27        DO_ICALL                                         $20     
         28        ASSIGN                                                   !3, $20
   34    29        INIT_FCALL                                               'print_r'
         30        SEND_VAR                                                 !3
         31        DO_ICALL                                                 
         32      > RETURN                                                   1

Class Bar: [no user functions]
Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oAhZZ
function name:  __construct
number of ops:  4
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        ASSIGN_OBJ                                               'test'
          2        OP_DATA                                                  !0
          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/oAhZZ
function name:  serialize
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   FETCH_OBJ_R                                      ~0      'test'
          1      > RETURN                                                   ~0
    9     2*     > 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/oAhZZ
function name:  unserialize
number of ops:  7
compiled vars:  !0 = $serialized
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   13     1        INIT_FCALL                                               'unserialize'
          2        SEND_VAL                                                 'O%3A3%3A%22Bar%22%3A1%3A%7Bs%3A4%3A%22bar1%22%3BO%3A3%3A%22Bar%22%3A0%3A%7B%7D%7D'
          3        DO_ICALL                                                 
   14     4        ASSIGN_OBJ                                               'test'
          5        OP_DATA                                                  !0
   15     6      > RETURN                                                   null

End of function unserialize

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.51 ms | 1400 KiB | 19 Q