3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL); # export ... simulates exporting old data where class Foo didn't implement Serializable $mode = (isset($argv[1]) && $argv[1] === 'import') ? 'import' : 'export'; if ($mode === 'export') { class Foo { protected $foo = null; public function __construct() { $this->foo = "something"; } } $foo = new Foo(); $data = serialize($foo); file_put_contents('/tmp/phpbug', $data); } else { class Foo implements Serializable { protected $foo = null; public function __construct() { $this->foo = "something"; } public function serialize() { echo __CLASS__ . "::serialize called\n"; return $this->foo; } public function unserialize($data) { echo __CLASS__ . "::unserialize called\n"; $this->foo = $data; } } $data = file_get_contents('/tmp/phpbug'); $foo = unserialize($data); if ($foo instanceof Foo) echo "Thumbs up!\n"; else echo "Unserialize FAILED\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 28
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 41
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 28
Branch analysis from position: 15
Branch analysis from position: 28
Branch analysis from position: 8
filename:       /in/IL22B
function name:  (null)
number of ops:  43
compiled vars:  !0 = $mode, !1 = $argv, !2 = $foo, !3 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'error_reporting'
          1        SEND_VAL                                                 32767
          2        DO_ICALL                                                 
    6     3        ISSET_ISEMPTY_DIM_OBJ                         0  ~5      !1, 1
          4      > JMPZ_EX                                          ~5      ~5, ->8
          5    >   FETCH_DIM_R                                      ~6      !1, 1
          6        IS_IDENTICAL                                     ~7      ~6, 'import'
          7        BOOL                                             ~5      ~7
          8    > > JMPZ                                                     ~5, ->11
          9    >   QM_ASSIGN                                        ~8      'import'
         10      > JMP                                                      ->12
         11    >   QM_ASSIGN                                        ~8      'export'
         12    >   ASSIGN                                                   !0, ~8
    8    13        IS_IDENTICAL                                             !0, 'export'
         14      > JMPZ                                                     ~10, ->28
   10    15    >   DECLARE_CLASS                                            'foo'
   20    16        NEW                                              $11     'Foo'
         17        DO_FCALL                                      0          
         18        ASSIGN                                                   !2, $11
   21    19        INIT_FCALL                                               'serialize'
         20        SEND_VAR                                                 !2
         21        DO_ICALL                                         $14     
         22        ASSIGN                                                   !3, $14
   22    23        INIT_FCALL                                               'file_put_contents'
         24        SEND_VAL                                                 '%2Ftmp%2Fphpbug'
         25        SEND_VAR                                                 !3
         26        DO_ICALL                                                 
         27      > JMP                                                      ->42
   26    28    >   DECLARE_CLASS                                            'foo'
   48    29        INIT_FCALL                                               'file_get_contents'
         30        SEND_VAL                                                 '%2Ftmp%2Fphpbug'
         31        DO_ICALL                                         $17     
         32        ASSIGN                                                   !3, $17
   49    33        INIT_FCALL                                               'unserialize'
         34        SEND_VAR                                                 !3
         35        DO_ICALL                                         $19     
         36        ASSIGN                                                   !2, $19
   50    37        INSTANCEOF                                               !2, 'Foo'
         38      > JMPZ                                                     ~21, ->41
   51    39    >   ECHO                                                     'Thumbs+up%21%0A'
         40      > JMP                                                      ->42
   53    41    >   ECHO                                                     'Unserialize+FAILED%0A'
   54    42    > > RETURN                                                   1

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IL22B
function name:  __construct
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   ASSIGN_OBJ                                               'foo'
          1        OP_DATA                                                  'something'
   17     2      > RETURN                                                   null

End of function __construct

End of class Foo.

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IL22B
function name:  __construct
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   ASSIGN_OBJ                                               'foo'
          1        OP_DATA                                                  'something'
   33     2      > 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/IL22B
function name:  serialize
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   ECHO                                                     'Foo%3A%3Aserialize+called%0A'
   38     1        FETCH_OBJ_R                                      ~0      'foo'
          2      > RETURN                                                   ~0
   39     3*     > 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/IL22B
function name:  unserialize
number of ops:  5
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   RECV                                             !0      
   43     1        ECHO                                                     'Foo%3A%3Aunserialize+called%0A'
   44     2        ASSIGN_OBJ                                               'foo'
          3        OP_DATA                                                  !0
   45     4      > RETURN                                                   null

End of function unserialize

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
234.02 ms | 1400 KiB | 23 Q