3v4l.org

run code in 300+ PHP versions simultaneously
<?php function myfunc(){ return 'works'; } define('func', 'myfunc'); (func)(); // Error: function "func" not defined $tokens = token_get_all('<?php function myfunc(){ echo \'works\'; } define(\'func\', \'myfunc\'); (func)();'); foreach ($tokens as $token) { if (is_array($token)) { echo "Line {$token[2]}: ", token_name($token[0]), " ('{$token[1]}')", PHP_EOL; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 32
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 32
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 31
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 31
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/uE4kg
function name:  (null)
number of ops:  34
compiled vars:  !0 = $tokens, !1 = $token
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'define'
          1        SEND_VAL                                                 'func'
          2        SEND_VAL                                                 'myfunc'
          3        DO_ICALL                                                 
    5     4        FETCH_CONSTANT                                   ~3      'func'
          5        INIT_DYNAMIC_CALL                                        ~3
          6        DO_FCALL                                      0          
    7     7        INIT_FCALL                                               'token_get_all'
          8        SEND_VAL                                                 '%3C%3Fphp+%0Afunction+myfunc%28%29%7B+echo+%27works%27%3B+%7D%0Adefine%28%27func%27%2C+%27myfunc%27%29%3B%0A%28func%29%28%29%3B'
          9        DO_ICALL                                         $5      
         10        ASSIGN                                                   !0, $5
   12    11      > FE_RESET_R                                       $7      !0, ->32
         12    > > FE_FETCH_R                                               $7, !1, ->32
   13    13    >   TYPE_CHECK                                  128          !1
         14      > JMPZ                                                     ~8, ->31
   14    15    >   ROPE_INIT                                     3  ~11     'Line+'
         16        FETCH_DIM_R                                      ~9      !1, 2
         17        ROPE_ADD                                      1  ~11     ~11, ~9
         18        ROPE_END                                      2  ~10     ~11, '%3A+'
         19        ECHO                                                     ~10
         20        INIT_FCALL                                               'token_name'
         21        FETCH_DIM_R                                      ~13     !1, 0
         22        SEND_VAL                                                 ~13
         23        DO_ICALL                                         $14     
         24        ECHO                                                     $14
         25        ROPE_INIT                                     3  ~17     '+%28%27'
         26        FETCH_DIM_R                                      ~15     !1, 1
         27        ROPE_ADD                                      1  ~17     ~17, ~15
         28        ROPE_END                                      2  ~16     ~17, '%27%29'
         29        ECHO                                                     ~16
         30        ECHO                                                     '%0A'
   12    31    > > JMP                                                      ->12
         32    >   FE_FREE                                                  $7
   16    33      > RETURN                                                   1

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

End of function myfunc

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
260.24 ms | 1009 KiB | 16 Q