3v4l.org

run code in 300+ PHP versions simultaneously
<?php class c1 { public $a = 1; public $b = 2; } class c2 implements Serializable { public $a = 1; public $b = 2; public function serialize() { return 's:1:"a";i:1;s:1:"b";i:2;'; } public function unserialize($str) { $this->a = 3; } public function __wakeup() { echo $this->a; } } $o1 = new c1; $o2 = new c2; echo $o_str = serialize($o1) . "\n"; echo $c_str = serialize($o2) . "\n"; $o_str = str_replace($o_str, "c1", "c2"); $o1 = unserialize($o_str); $o2 = unserialize($c_str);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KD0YR
function name:  (null)
number of ops:  34
compiled vars:  !0 = $o1, !1 = $o2, !2 = $o_str, !3 = $c_str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   DECLARE_CLASS                                            'c2'
   16     1        NEW                                              $4      'c1'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $4
   17     4        NEW                                              $7      'c2'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $7
   19     7        INIT_FCALL                                               'serialize'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $10     
         10        CONCAT                                           ~11     $10, '%0A'
         11        ASSIGN                                           ~12     !2, ~11
         12        ECHO                                                     ~12
   20    13        INIT_FCALL                                               'serialize'
         14        SEND_VAR                                                 !1
         15        DO_ICALL                                         $13     
         16        CONCAT                                           ~14     $13, '%0A'
         17        ASSIGN                                           ~15     !3, ~14
         18        ECHO                                                     ~15
   21    19        INIT_FCALL                                               'str_replace'
         20        SEND_VAR                                                 !2
         21        SEND_VAL                                                 'c1'
         22        SEND_VAL                                                 'c2'
         23        DO_ICALL                                         $16     
         24        ASSIGN                                                   !2, $16
   23    25        INIT_FCALL                                               'unserialize'
         26        SEND_VAR                                                 !2
         27        DO_ICALL                                         $18     
         28        ASSIGN                                                   !0, $18
   24    29        INIT_FCALL                                               'unserialize'
         30        SEND_VAR                                                 !3
         31        DO_ICALL                                         $20     
         32        ASSIGN                                                   !1, $20
         33      > RETURN                                                   1

Class c1: [no user functions]
Class c2:
Function serialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KD0YR
function name:  serialize
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E > > RETURN                                                   's%3A1%3A%22a%22%3Bi%3A1%3Bs%3A1%3A%22b%22%3Bi%3A2%3B'
          1*     > 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/KD0YR
function name:  unserialize
number of ops:  4
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        ASSIGN_OBJ                                               'a'
          2        OP_DATA                                                  3
          3      > RETURN                                                   null

End of function unserialize

Function __wakeup:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KD0YR
function name:  __wakeup
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   FETCH_OBJ_R                                      ~0      'a'
          1        ECHO                                                     ~0
   14     2      > RETURN                                                   null

End of function __wakeup

End of class c2.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
198.58 ms | 1400 KiB | 19 Q