3v4l.org

run code in 300+ PHP versions simultaneously
<?php $_GET['msg']="what is 5 + 5 ?"; $msg=$_GET['msg']??"no msg!"; file_put_contents('msg.log.txt',$msg."\r\n",FILE_APPEND|LOCK_EX); $matches=NULL; $isMatch=preg_match("/(\d+)\s*(\+|\-|\*|\/|\:)\s*(\d+)/",$msg,$matches); if($isMatch){ $l=(int)$matches[1]; $o=$matches[2]; $r=(int)$matches[3]; switch($o){ case '+': $res=$l+$r; break; case '-': $res=$l-$r; break; case '*': $res=$l*$r; break; case '\\': case ':': $res=$l/$r; break; default: throw new \LogicException("invalid operator passed regex??!"); } echo "!check {$res}"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 61
Branch analysis from position: 22
7 jumps found. (Code = 188) Position 1 = 42, Position 2 = 45, Position 3 = 48, Position 4 = 51, Position 5 = 51, Position 6 = 54, Position 7 = 31
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 45
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
Branch analysis from position: 51
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
Branch analysis from position: 51
Branch analysis from position: 54
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 42
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 45
Branch analysis from position: 35
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 48
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 51
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 51
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 54
Branch analysis from position: 54
Branch analysis from position: 51
Branch analysis from position: 51
Branch analysis from position: 48
Branch analysis from position: 45
Branch analysis from position: 42
Branch analysis from position: 61
filename:       /in/ZvsW3
function name:  (null)
number of ops:  62
compiled vars:  !0 = $msg, !1 = $matches, !2 = $isMatch, !3 = $l, !4 = $o, !5 = $r, !6 = $res
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   FETCH_W                      global              $7      '_GET'
          1        ASSIGN_DIM                                               $7, 'msg'
          2        OP_DATA                                                  'what+is+5+%2B+5+%3F'
    3     3        FETCH_IS                                         ~9      '_GET'
          4        FETCH_DIM_IS                                     ~10     ~9, 'msg'
          5        COALESCE                                         ~11     ~10
          6        QM_ASSIGN                                        ~11     'no+msg%21'
          7        ASSIGN                                                   !0, ~11
    4     8        INIT_FCALL                                               'file_put_contents'
          9        SEND_VAL                                                 'msg.log.txt'
         10        CONCAT                                           ~13     !0, '%0D%0A'
         11        SEND_VAL                                                 ~13
         12        SEND_VAL                                                 10
         13        DO_ICALL                                                 
    5    14        ASSIGN                                                   !1, null
    6    15        INIT_FCALL                                               'preg_match'
         16        SEND_VAL                                                 '%2F%28%5Cd%2B%29%5Cs%2A%28%5C%2B%7C%5C-%7C%5C%2A%7C%5C%2F%7C%5C%3A%29%5Cs%2A%28%5Cd%2B%29%2F'
         17        SEND_VAR                                                 !0
         18        SEND_REF                                                 !1
         19        DO_ICALL                                         $16     
         20        ASSIGN                                                   !2, $16
    7    21      > JMPZ                                                     !2, ->61
    8    22    >   FETCH_DIM_R                                      ~18     !1, 1
         23        CAST                                          4  ~19     ~18
         24        ASSIGN                                                   !3, ~19
    9    25        FETCH_DIM_R                                      ~21     !1, 2
         26        ASSIGN                                                   !4, ~21
   10    27        FETCH_DIM_R                                      ~23     !1, 3
         28        CAST                                          4  ~24     ~23
         29        ASSIGN                                                   !5, ~24
   11    30      > SWITCH_STRING                                            !4, [ '%2B':->42, '-':->45, '%2A':->48, '%5C':->51, '%3A':->51, ], ->54
   12    31    >   IS_EQUAL                                                 !4, '%2B'
         32      > JMPNZ                                                    ~26, ->42
   15    33    >   IS_EQUAL                                                 !4, '-'
         34      > JMPNZ                                                    ~26, ->45
   18    35    >   IS_EQUAL                                                 !4, '%2A'
         36      > JMPNZ                                                    ~26, ->48
   21    37    >   IS_EQUAL                                                 !4, '%5C'
         38      > JMPNZ                                                    ~26, ->51
   22    39    >   IS_EQUAL                                                 !4, '%3A'
         40      > JMPNZ                                                    ~26, ->51
         41    > > JMP                                                      ->54
   13    42    >   ADD                                              ~27     !3, !5
         43        ASSIGN                                                   !6, ~27
   14    44      > JMP                                                      ->58
   16    45    >   SUB                                              ~29     !3, !5
         46        ASSIGN                                                   !6, ~29
   17    47      > JMP                                                      ->58
   19    48    >   MUL                                              ~31     !3, !5
         49        ASSIGN                                                   !6, ~31
   20    50      > JMP                                                      ->58
   23    51    >   DIV                                              ~33     !3, !5
         52        ASSIGN                                                   !6, ~33
   24    53      > JMP                                                      ->58
   26    54    >   NEW                                              $35     'LogicException'
         55        SEND_VAL_EX                                              'invalid+operator+passed+regex%3F%3F%21'
         56        DO_FCALL                                      0          
         57      > THROW                                         0          $35
   28    58    >   NOP                                                      
         59        FAST_CONCAT                                      ~37     '%21check+', !6
         60        ECHO                                                     ~37
   29    61    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.05 ms | 1404 KiB | 17 Q