3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function __sleep() { return []; } public function __wakeup() { echo 'Called ' . __METHOD__ . PHP_EOL; } } class Bar implements \Serializable { private $foo; public function __construct(Foo $foo) { $this->foo = $foo; } public function serialize() { return serialize($this->foo); } public function unserialize($serialized) { echo 'unserialize Foo' . PHP_EOL; $this->foo = unserialize($serialized); echo 'end unserialize Foo' . PHP_EOL; } } $foo = new Foo(); $bar = new Bar($foo); $barStr = serialize($bar); $newBar = unserialize($barStr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MlbuO
function name:  (null)
number of ops:  17
compiled vars:  !0 = $foo, !1 = $bar, !2 = $barStr, !3 = $newBar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   DECLARE_CLASS                                            'bar'
   37     1        NEW                                              $4      'Foo'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $4
   38     4        NEW                                              $7      'Bar'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $7
   39     8        INIT_FCALL                                               'serialize'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                         $10     
         11        ASSIGN                                                   !2, $10
   40    12        INIT_FCALL                                               'unserialize'
         13        SEND_VAR                                                 !2
         14        DO_ICALL                                         $12     
         15        ASSIGN                                                   !3, $12
         16      > RETURN                                                   1

Class Foo:
Function __sleep:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MlbuO
function name:  __sleep
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E > > RETURN                                                   <array>
    7     1*     > RETURN                                                   null

End of function __sleep

Function __wakeup:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MlbuO
function name:  __wakeup
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ECHO                                                     'Called+Foo%3A%3A__wakeup%0A'
   12     1      > RETURN                                                   null

End of function __wakeup

End of class Foo.

Class Bar:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MlbuO
function name:  __construct
number of ops:  4
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   21     1        ASSIGN_OBJ                                               'foo'
          2        OP_DATA                                                  !0
   22     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/MlbuO
function name:  serialize
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   INIT_FCALL                                               'serialize'
          1        FETCH_OBJ_R                                      ~0      'foo'
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
   27     5*     > 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/MlbuO
function name:  unserialize
number of ops:  9
compiled vars:  !0 = $serialized
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
   31     1        ECHO                                                     'unserialize+Foo%0A'
   32     2        INIT_FCALL                                               'unserialize'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $2      
          5        ASSIGN_OBJ                                               'foo'
          6        OP_DATA                                                  $2
   33     7        ECHO                                                     'end+unserialize+Foo%0A'
   34     8      > RETURN                                                   null

End of function unserialize

End of class Bar.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
202.96 ms | 1400 KiB | 17 Q