3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = '((800 + 20) - 800 / 2)'; $tokens = token_get_all("<?php {$input}"); echo '$tokens'; $expr = ''; foreach($tokens as $token){ if(is_string($token)){ if(in_array($token, array('(', ')', '+', '-', '/', '*'), true)) $expr .= $token; continue; } list($id, $text) = $token; if(in_array($id, array(T_DNUMBER, T_LNUMBER))) $expr .= $text; } 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 = 30
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 30
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 17
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 16
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 16
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 29
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 29
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/9BYMK
function name:  (null)
number of ops:  40
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%28800+%2B+20%29+-+800+%2F+2%29'
    5     1        INIT_FCALL                                               'token_get_all'
          2        NOP                                                      
          3        FAST_CONCAT                                      ~8      '%3C%3Fphp+', !0
          4        SEND_VAL                                                 ~8
          5        DO_ICALL                                         $9      
          6        ASSIGN                                                   !1, $9
    6     7        ECHO                                                     '%24tokens'
    7     8        ASSIGN                                                   !2, ''
    9     9      > FE_RESET_R                                       $12     !1, ->30
         10    > > FE_FETCH_R                                               $12, !3, ->30
   11    11    >   TYPE_CHECK                                   64          !3
         12      > JMPZ                                                     ~13, ->17
   13    13    >   IN_ARRAY                                                 !3, <array>
         14      > JMPZ                                                     ~14, ->16
   14    15    >   ASSIGN_OP                                     8          !2, !3
   16    16    > > JMP                                                      ->10
   19    17    >   QM_ASSIGN                                        ~16     !3
         18        FETCH_LIST_R                                     $17     ~16, 0
         19        ASSIGN                                                   !4, $17
         20        FETCH_LIST_R                                     $19     ~16, 1
         21        ASSIGN                                                   !5, $19
         22        FREE                                                     ~16
   21    23        INIT_FCALL                                               'in_array'
         24        SEND_VAR                                                 !4
         25        SEND_VAL                                                 <array>
         26        DO_ICALL                                         $21     
         27      > JMPZ                                                     $21, ->29
   22    28    >   ASSIGN_OP                                     8          !2, !5
    9    29    > > JMP                                                      ->10
         30    >   FE_FREE                                                  $12
   25    31        ROPE_INIT                                     3  ~24     '%24result+%3D+'
         32        ROPE_ADD                                      1  ~24     ~24, !2
         33        ROPE_END                                      2  ~23     ~24, '%3B'
         34        INCLUDE_OR_EVAL                                          ~23, EVAL
   27    35        CONCAT                                           ~27     '%0Aexpr+%3D+', !2
         36        ECHO                                                     ~27
   28    37        CONCAT                                           ~28     '%0Ares+%3D+', !6
         38        ECHO                                                     ~28
         39      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.21 ms | 1400 KiB | 17 Q