3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = '$x=100; ((800 + 20) - 800 / 2)'; $tokens = token_get_all("<?php {$input}"); $expr = ''; foreach($tokens as $token){ if(in_array($token, array(T_DNUMBER, T_LNUMBER, T_BOOLEAN_AND, T_BOOLEAN_OR, T_DEC, T_DIV_EQUAL,T_DOUBLE_CAST,T_ELSE,T_ELSEIF, T_ENDIF,T_IF,T_INC, T_IS_EQUAL, T_IS_GREATER_OR_EQUAL,T_IS_IDENTICAL,T_IS_NOT_EQUAL, T_IS_NOT_IDENTICAL, T_IS_SMALLER_OR_EQUAL, T_LOGICAL_AND , T_LOGICAL_OR ,T_MINUS_EQUAL,T_MOD_EQUAL, T_MUL_EQUAL, T_OR_EQUAL, T_PLUS_EQUAL, T_POW, T_POW_EQUAL , T_STRING_VARNAME,T_VARIABLE , T_XOR_EQUAL ))) echo $token; if(is_string($token)){ if(in_array($token, array('(', ')', '+', '-', '/', '*','if','IF' , '{' ,'}' , ';' ,'$'), 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 = 35
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 35
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 16
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 22
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 21
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 21
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 34
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 34
Branch analysis from position: 16
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
filename:       /in/881Xl
function name:  (null)
number of ops:  45
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, '%24x%3D100%3B+%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        ASSIGN                                                   !2, ''
    8     8      > FE_RESET_R                                       $12     !1, ->35
          9    > > FE_FETCH_R                                               $12, !3, ->35
   10    10    >   INIT_FCALL                                               'in_array'
         11        SEND_VAR                                                 !3
         12        SEND_VAL                                                 <array>
         13        DO_ICALL                                         $13     
         14      > JMPZ                                                     $13, ->16
   11    15    >   ECHO                                                     !3
   13    16    >   TYPE_CHECK                                   64          !3
         17      > JMPZ                                                     ~14, ->22
   15    18    >   IN_ARRAY                                                 !3, <array>
         19      > JMPZ                                                     ~15, ->21
   16    20    >   ASSIGN_OP                                     8          !2, !3
   18    21    > > JMP                                                      ->9
   21    22    >   QM_ASSIGN                                        ~17     !3
         23        FETCH_LIST_R                                     $18     ~17, 0
         24        ASSIGN                                                   !4, $18
         25        FETCH_LIST_R                                     $20     ~17, 1
         26        ASSIGN                                                   !5, $20
         27        FREE                                                     ~17
   23    28        INIT_FCALL                                               'in_array'
         29        SEND_VAR                                                 !4
         30        SEND_VAL                                                 <array>
         31        DO_ICALL                                         $22     
         32      > JMPZ                                                     $22, ->34
   24    33    >   ASSIGN_OP                                     8          !2, !5
    8    34    > > JMP                                                      ->9
         35    >   FE_FREE                                                  $12
   27    36        ROPE_INIT                                     3  ~25     '%24result+%3D+'
         37        ROPE_ADD                                      1  ~25     ~25, !2
         38        ROPE_END                                      2  ~24     ~25, '%3B'
         39        INCLUDE_OR_EVAL                                          ~24, EVAL
   29    40        CONCAT                                           ~28     '%0Aexpr+%3D+', !2
         41        ECHO                                                     ~28
   30    42        CONCAT                                           ~29     '%0Ares+%3D+', !6
         43        ECHO                                                     ~29
   31    44      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.69 ms | 1405 KiB | 17 Q