3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $mVars; public function generateVars() { $this->mVars = [ 'x', 'y', 'z' ]; } public function dumpVars() { var_dump( $this->mVars ); } } // 1. Make mVars public, uncomment line 16, then eval. $before = new Foo(); $before->generateVars(); // echo serialize($before) . "\n"; define('BEFORE', 1); // 2. Insert the serialised text from first eval $serialised = 'O:3:"Foo":1:{s:5:"mVars";a:3:{i:0;s:1:"x";i:1;s:1:"y";i:2;s:1:"z";}}'; // 3. Make mVars private, comment out line 16, then eval $after = unserialize($serialised); $after->dumpVars();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7XTJj
function name:  (null)
number of ops:  13
compiled vars:  !0 = $before, !1 = $serialised, !2 = $after
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   NEW                                              $3      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   15     3        INIT_METHOD_CALL                                         !0, 'generateVars'
          4        DO_FCALL                                      0          
   19     5        ASSIGN                                                   !1, 'O%3A3%3A%22Foo%22%3A1%3A%7Bs%3A5%3A%22mVars%22%3Ba%3A3%3A%7Bi%3A0%3Bs%3A1%3A%22x%22%3Bi%3A1%3Bs%3A1%3A%22y%22%3Bi%3A2%3Bs%3A1%3A%22z%22%3B%7D%7D'
   22     6        INIT_FCALL                                               'unserialize'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $8      
          9        ASSIGN                                                   !2, $8
   23    10        INIT_METHOD_CALL                                         !2, 'dumpVars'
         11        DO_FCALL                                      0          
         12      > RETURN                                                   1

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

End of function generatevars

Function dumpvars:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7XTJj
function name:  dumpVars
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                               'var_dump'
          1        FETCH_OBJ_R                                      ~0      'mVars'
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                                 
   10     4      > RETURN                                                   null

End of function dumpvars

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
179.01 ms | 1396 KiB | 17 Q