3v4l.org

run code in 300+ PHP versions simultaneously
<?php function mask($ip, $cdir) { list ($net, $mask) = explode("/", $cdir); return ((ip2long($ip) & (~((1 << (32 - $mask)) - 1))) == ip2long($net)); } $ip = '104.192.143.208'; if (!mask($ip, '104.192.143.192/28') && !mask($ip, '104.192.143.208/28')) { echo "not allowed"; } else { echo "allowed"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 7, Position 2 = 13
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/9Og6Y
function name:  (null)
number of ops:  18
compiled vars:  !0 = $ip
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ASSIGN                                                   !0, '104.192.143.208'
   11     1        INIT_FCALL                                               'mask'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 '104.192.143.192%2F28'
          4        DO_FCALL                                      0  $2      
          5        BOOL_NOT                                         ~3      $2
          6      > JMPZ_EX                                          ~3      ~3, ->13
          7    >   INIT_FCALL                                               'mask'
          8        SEND_VAR                                                 !0
          9        SEND_VAL                                                 '104.192.143.208%2F28'
         10        DO_FCALL                                      0  $4      
         11        BOOL_NOT                                         ~5      $4
         12        BOOL                                             ~3      ~5
         13    > > JMPZ                                                     ~3, ->16
   12    14    >   ECHO                                                     'not+allowed'
         15      > JMP                                                      ->17
   14    16    >   ECHO                                                     'allowed'
   15    17    > > RETURN                                                   1

Function mask:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9Og6Y
function name:  mask
number of ops:  25
compiled vars:  !0 = $ip, !1 = $cdir, !2 = $net, !3 = $mask
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '%2F'
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $4      
          6        FETCH_LIST_R                                     $5      $4, 0
          7        ASSIGN                                                   !2, $5
          8        FETCH_LIST_R                                     $7      $4, 1
          9        ASSIGN                                                   !3, $7
         10        FREE                                                     $4
    6    11        INIT_FCALL                                               'ip2long'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $9      
         14        SUB                                              ~10     32, !3
         15        SL                                               ~11     1, ~10
         16        SUB                                              ~12     ~11, 1
         17        BW_NOT                                           ~13     ~12
         18        BW_AND                                           ~14     $9, ~13
         19        INIT_FCALL                                               'ip2long'
         20        SEND_VAR                                                 !2
         21        DO_ICALL                                         $15     
         22        IS_EQUAL                                         ~16     $15, ~14
         23      > RETURN                                                   ~16
    7    24*     > RETURN                                                   null

End of function mask

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.93 ms | 1394 KiB | 19 Q