3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = '((\'rats\' + \'stoats\') - 800 / 2)'; $tokens = token_get_all("<?php {$input} ?>"); $expr = ''; foreach($tokens as $token){ print "\ntokens = " . $token; if(is_string($token)){ if(in_array($token, array('(', ')', '+', '-', '/', '*'), true)){ $expr .= $token; print "\n symbol: " . $expr; } continue; } list($id, $text) = $token; if(in_array($id, array(T_DNUMBER, T_LNUMBER,T_CONSTANT_ENCAPSED_STRING))){ $expr .= $text; print "\n number: " . $expr; } } eval("\$result = {$expr};"); print "\nexpr = " . $expr; print "\nres = " . $result;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 36
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 36
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 21
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 20
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 20
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 35
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 35
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
filename:       /in/8K73Q
function name:  (null)
number of ops:  46
compiled vars:  !0 = $input, !1 = $tokens, !2 = $expr, !3 = $token, !4 = $id, !5 = $text, !6 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%28%28%27rats%27+%2B+%27stoats%27%29+-+800+%2F+2%29'
    5     1        INIT_FCALL                                               'token_get_all'
          2        ROPE_INIT                                     3  ~9      '%3C%3Fphp+'
          3        ROPE_ADD                                      1  ~9      ~9, !0
          4        ROPE_END                                      2  ~8      ~9, '+%3F%3E'
          5        SEND_VAL                                                 ~8
          6        DO_ICALL                                         $11     
          7        ASSIGN                                                   !1, $11
    7     8        ASSIGN                                                   !2, ''
    9     9      > FE_RESET_R                                       $14     !1, ->36
         10    > > FE_FETCH_R                                               $14, !3, ->36
   10    11    >   CONCAT                                           ~15     '%0Atokens+%3D+', !3
         12        ECHO                                                     ~15
   11    13        TYPE_CHECK                                   64          !3
         14      > JMPZ                                                     ~16, ->21
   13    15    >   IN_ARRAY                                                 !3, <array>
         16      > JMPZ                                                     ~17, ->20
   14    17    >   ASSIGN_OP                                     8          !2, !3
   15    18        CONCAT                                           ~19     '%0A+symbol%3A+', !2
         19        ECHO                                                     ~19
   17    20    > > JMP                                                      ->10
   20    21    >   QM_ASSIGN                                        ~20     !3
         22        FETCH_LIST_R                                     $21     ~20, 0
         23        ASSIGN                                                   !4, $21
         24        FETCH_LIST_R                                     $23     ~20, 1
         25        ASSIGN                                                   !5, $23
         26        FREE                                                     ~20
   22    27        INIT_FCALL                                               'in_array'
         28        SEND_VAR                                                 !4
         29        SEND_VAL                                                 <array>
         30        DO_ICALL                                         $25     
         31      > JMPZ                                                     $25, ->35
   23    32    >   ASSIGN_OP                                     8          !2, !5
   24    33        CONCAT                                           ~27     '%0A+number%3A+', !2
         34        ECHO                                                     ~27
    9    35    > > JMP                                                      ->10
         36    >   FE_FREE                                                  $14
   28    37        ROPE_INIT                                     3  ~29     '%24result+%3D+'
         38        ROPE_ADD                                      1  ~29     ~29, !2
         39        ROPE_END                                      2  ~28     ~29, '%3B'
         40        INCLUDE_OR_EVAL                                          ~28, EVAL
   30    41        CONCAT                                           ~32     '%0Aexpr+%3D+', !2
         42        ECHO                                                     ~32
   31    43        CONCAT                                           ~33     '%0Ares+%3D+', !6
         44        ECHO                                                     ~33
         45      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.26 ms | 1400 KiB | 17 Q