3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = 10; $b = 20; $c = 30; $d = 40; $defined_variables = get_defined_vars(); $variables2keep = array("a", "b", "c"); foreach($defined_variables as $variable => $value) if(!in_array($variable, $variables2keep)) unset($$variable); print_r(get_defined_vars());
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 19
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 19
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 18
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 18
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/3tQ45
function name:  (null)
number of ops:  26
compiled vars:  !0 = $a, !1 = $b, !2 = $c, !3 = $d, !4 = $defined_variables, !5 = $variables2keep, !6 = $value, !7 = $variable
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 10
    3     1        ASSIGN                                                   !1, 20
    4     2        ASSIGN                                                   !2, 30
    5     3        ASSIGN                                                   !3, 40
    6     4        INIT_FCALL                                               'get_defined_vars'
          5        DO_ICALL                                         $12     
          6        ASSIGN                                                   !4, $12
    7     7        ASSIGN                                                   !5, <array>
    8     8      > FE_RESET_R                                       $15     !4, ->19
          9    > > FE_FETCH_R                                       ~16     $15, !6, ->19
         10    >   ASSIGN                                                   !7, ~16
         11        INIT_FCALL                                               'in_array'
         12        SEND_VAR                                                 !7
         13        SEND_VAR                                                 !5
         14        DO_ICALL                                         $18     
         15        BOOL_NOT                                         ~19     $18
         16      > JMPZ                                                     ~19, ->18
         17    >   UNSET_VAR                                                !7
         18    > > JMP                                                      ->9
         19    >   FE_FREE                                                  $15
    9    20        INIT_FCALL                                               'print_r'
         21        INIT_FCALL                                               'get_defined_vars'
         22        DO_ICALL                                         $20     
         23        SEND_VAR                                                 $20
         24        DO_ICALL                                                 
         25      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.31 ms | 1401 KiB | 19 Q