3v4l.org

run code in 300+ PHP versions simultaneously
<?php // overly simplified example function test1() { $a = 3; test2(); } function test2() { echo $a; } // the actual idea is to do something like this // main.php $vars = []; function load_file($path) { if(is_file($path)) { $GLOBALS['path'] = $path; load_isolated(); } } function load_isolated() { extract($GLOBALS['vars']); require($GLOBALS['path']); $GLOBALS['vars'] = get_defined_vars(); } load_file('a.php'); // a.php $a = 3; load_file('b.php'); //b.php echo $a; // warning or error that var $a doesn't exist because get_defined_vars() was never called yata yata
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YHebC
function name:  (null)
number of ops:  10
compiled vars:  !0 = $vars, !1 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ASSIGN                                                   !0, <array>
   32     1        INIT_FCALL                                               'load_file'
          2        SEND_VAL                                                 'a.php'
          3        DO_FCALL                                      0          
   35     4        ASSIGN                                                   !1, 3
   36     5        INIT_FCALL                                               'load_file'
          6        SEND_VAL                                                 'b.php'
          7        DO_FCALL                                      0          
   39     8        ECHO                                                     !1
          9      > RETURN                                                   1

Function test1:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YHebC
function name:  test1
number of ops:  4
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   ASSIGN                                                   !0, 3
    7     1        INIT_FCALL_BY_NAME                                       'test2'
          2        DO_FCALL                                      0          
    8     3      > RETURN                                                   null

End of function test1

Function test2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YHebC
function name:  test2
number of ops:  2
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ECHO                                                     !0
   12     1      > RETURN                                                   null

End of function test2

Function load_file:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/YHebC
function name:  load_file
number of ops:  11
compiled vars:  !0 = $path
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   20     1        INIT_FCALL                                               'is_file'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4      > JMPZ                                                     $1, ->10
   22     5    >   FETCH_W                      global              $2      'GLOBALS'
          6        ASSIGN_DIM                                               $2, 'path'
          7        OP_DATA                                                  !0
   23     8        INIT_FCALL_BY_NAME                                       'load_isolated'
          9        DO_FCALL                                      0          
   25    10    > > RETURN                                                   null

End of function load_file

Function load_isolated:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YHebC
function name:  load_isolated
number of ops:  14
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   INIT_FCALL                                               'extract'
          1        FETCH_W                      global              $0      'GLOBALS'
          2        FETCH_DIM_W                                      $1      $0, 'vars'
          3        SEND_REF                                                 $1
          4        DO_ICALL                                                 
   29     5        FETCH_R                      global              ~3      'GLOBALS'
          6        FETCH_DIM_R                                      ~4      ~3, 'path'
          7        INCLUDE_OR_EVAL                                          ~4, REQUIRE
   30     8        INIT_FCALL                                               'get_defined_vars'
          9        DO_ICALL                                         $8      
         10        FETCH_W                      global              $6      'GLOBALS'
         11        ASSIGN_DIM                                               $6, 'vars'
         12        OP_DATA                                                  $8
   31    13      > RETURN                                                   null

End of function load_isolated

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.8 ms | 1403 KiB | 21 Q