3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = '20-5*2/30+9='; $inputLength = mb_strlen($input); $number = 0; $result = 0; $op = ''; for ($i = 0; $i < $inputLength; $i++) { $char = mb_substr($input, $i, 1); if ($char == '*' || $char == '+' || $char == '-' || $char == '=' || $char == '/') { if ($op == '') { $result = $number; } elseif ($op == '+') { $result += $number; } elseif ($op == '-') { $result -= $number; } elseif ($op == '*') { $result *= $number; } elseif ($op == '/') { $result /= $number; } echo "op[$op] result[$result] number[$number] char[$char] \n"; $op = $char; $number = 0; if ($char == '=') { echo "Ответ: $input$result"; } } elseif (is_numeric($char) || $char == '.') { $number = $number * 10 + intval($char); } else { echo "Неверный символ:'$char\n"; exit(); } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 86
Branch analysis from position: 86
2 jumps found. (Code = 44) Position 1 = 88, Position 2 = 10
Branch analysis from position: 88
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 47) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
2 jumps found. (Code = 47) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
2 jumps found. (Code = 47) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
2 jumps found. (Code = 47) Position 1 = 27, Position 2 = 29
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 68
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 34
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
2 jumps found. (Code = 43) Position 1 = 63, Position 2 = 67
Branch analysis from position: 63
1 jumps found. (Code = 42) Position 1 = 85
Branch analysis from position: 85
2 jumps found. (Code = 44) Position 1 = 88, Position 2 = 10
Branch analysis from position: 88
Branch analysis from position: 10
Branch analysis from position: 67
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 38
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
Branch analysis from position: 38
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 42
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
Branch analysis from position: 42
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 46
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
Branch analysis from position: 46
2 jumps found. (Code = 43) Position 1 = 48, Position 2 = 49
Branch analysis from position: 48
2 jumps found. (Code = 43) Position 1 = 63, Position 2 = 67
Branch analysis from position: 63
Branch analysis from position: 67
Branch analysis from position: 49
Branch analysis from position: 68
2 jumps found. (Code = 47) Position 1 = 72, Position 2 = 74
Branch analysis from position: 72
2 jumps found. (Code = 43) Position 1 = 75, Position 2 = 80
Branch analysis from position: 75
1 jumps found. (Code = 42) Position 1 = 85
Branch analysis from position: 85
Branch analysis from position: 80
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 74
Branch analysis from position: 29
Branch analysis from position: 26
Branch analysis from position: 23
Branch analysis from position: 20
filename:       /in/D5Apr
function name:  (null)
number of ops:  89
compiled vars:  !0 = $input, !1 = $inputLength, !2 = $number, !3 = $result, !4 = $op, !5 = $i, !6 = $char
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '20-5%2A2%2F30%2B9%3D'
    4     1        INIT_FCALL                                               'mb_strlen'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $8      
          4        ASSIGN                                                   !1, $8
    5     5        ASSIGN                                                   !2, 0
    6     6        ASSIGN                                                   !3, 0
    7     7        ASSIGN                                                   !4, ''
    8     8        ASSIGN                                                   !5, 0
          9      > JMP                                                      ->86
    9    10    >   INIT_FCALL                                               'mb_substr'
         11        SEND_VAR                                                 !0
         12        SEND_VAR                                                 !5
         13        SEND_VAL                                                 1
         14        DO_ICALL                                         $14     
         15        ASSIGN                                                   !6, $14
   10    16        IS_EQUAL                                         ~16     !6, '%2A'
         17      > JMPNZ_EX                                         ~16     ~16, ->20
         18    >   IS_EQUAL                                         ~17     !6, '%2B'
         19        BOOL                                             ~16     ~17
         20    > > JMPNZ_EX                                         ~16     ~16, ->23
         21    >   IS_EQUAL                                         ~18     !6, '-'
         22        BOOL                                             ~16     ~18
         23    > > JMPNZ_EX                                         ~16     ~16, ->26
         24    >   IS_EQUAL                                         ~19     !6, '%3D'
         25        BOOL                                             ~16     ~19
         26    > > JMPNZ_EX                                         ~16     ~16, ->29
         27    >   IS_EQUAL                                         ~20     !6, '%2F'
         28        BOOL                                             ~16     ~20
         29    > > JMPZ                                                     ~16, ->68
   11    30    >   IS_EQUAL                                                 !4, ''
         31      > JMPZ                                                     ~21, ->34
   12    32    >   ASSIGN                                                   !3, !2
   11    33      > JMP                                                      ->49
   13    34    >   IS_EQUAL                                                 !4, '%2B'
         35      > JMPZ                                                     ~23, ->38
   14    36    >   ASSIGN_OP                                     1          !3, !2
   13    37      > JMP                                                      ->49
   15    38    >   IS_EQUAL                                                 !4, '-'
         39      > JMPZ                                                     ~25, ->42
   16    40    >   ASSIGN_OP                                     2          !3, !2
   15    41      > JMP                                                      ->49
   17    42    >   IS_EQUAL                                                 !4, '%2A'
         43      > JMPZ                                                     ~27, ->46
   18    44    >   ASSIGN_OP                                     3          !3, !2
   17    45      > JMP                                                      ->49
   19    46    >   IS_EQUAL                                                 !4, '%2F'
         47      > JMPZ                                                     ~29, ->49
   20    48    >   ASSIGN_OP                                     4          !3, !2
   22    49    >   ROPE_INIT                                     9  ~32     'op%5B'
         50        ROPE_ADD                                      1  ~32     ~32, !4
         51        ROPE_ADD                                      2  ~32     ~32, '%5D+result%5B'
         52        ROPE_ADD                                      3  ~32     ~32, !3
         53        ROPE_ADD                                      4  ~32     ~32, '%5D+number%5B'
         54        ROPE_ADD                                      5  ~32     ~32, !2
         55        ROPE_ADD                                      6  ~32     ~32, '%5D+char%5B'
         56        ROPE_ADD                                      7  ~32     ~32, !6
         57        ROPE_END                                      8  ~31     ~32, '%5D+%0A'
         58        ECHO                                                     ~31
   23    59        ASSIGN                                                   !4, !6
   24    60        ASSIGN                                                   !2, 0
   25    61        IS_EQUAL                                                 !6, '%3D'
         62      > JMPZ                                                     ~39, ->67
   26    63    >   ROPE_INIT                                     3  ~41     '%D0%9E%D1%82%D0%B2%D0%B5%D1%82%3A+'
         64        ROPE_ADD                                      1  ~41     ~41, !0
         65        ROPE_END                                      2  ~40     ~41, !3
         66        ECHO                                                     ~40
   10    67    > > JMP                                                      ->85
   28    68    >   INIT_FCALL                                               'is_numeric'
         69        SEND_VAR                                                 !6
         70        DO_ICALL                                         $43     
         71      > JMPNZ_EX                                         ~44     $43, ->74
         72    >   IS_EQUAL                                         ~45     !6, '.'
         73        BOOL                                             ~44     ~45
         74    > > JMPZ                                                     ~44, ->80
   29    75    >   MUL                                              ~46     !2, 10
         76        CAST                                          4  ~47     !6
         77        ADD                                              ~48     ~46, ~47
         78        ASSIGN                                                   !2, ~48
   28    79      > JMP                                                      ->85
   31    80    >   ROPE_INIT                                     3  ~51     '%D0%9D%D0%B5%D0%B2%D0%B5%D1%80%D0%BD%D1%8B%D0%B9+%D1%81%D0%B8%D0%BC%D0%B2%D0%BE%D0%BB%3A%27'
         81        ROPE_ADD                                      1  ~51     ~51, !6
         82        ROPE_END                                      2  ~50     ~51, '%0A'
         83        ECHO                                                     ~50
   32    84      > EXIT                                                     
    8    85    >   PRE_INC                                                  !5
         86    >   IS_SMALLER                                               !5, !1
         87      > JMPNZ                                                    ~54, ->10
   34    88    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
242.73 ms | 1009 KiB | 16 Q