3v4l.org

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.71 ms | 1405 KiB | 17 Q