3v4l.org

run code in 300+ PHP versions simultaneously
<?php function ipCidrCheck($IP, $CIDRArray) { foreach ($CIDRArray as $CIDR) { if (preg_match('#/#', $CIDR)) { list ($net, $mask) = split("/", $CIDR); } else { $net = $CIDR; $mask = 32; } $ip_net = ip2long($net); $ip_mask = ~((1 << (32 - $mask)) - 1); $ip_ip = ip2long($IP); $ip_ip_net = $ip_ip & $ip_mask; if ($ip_ip_net == $ip_net) { return true; } } return false; } var_dump(ipCidrCheck('167.98.48.102', ['167.98.48.*']));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/clEqo
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'ipcidrcheck'
          2        SEND_VAL                                                 '167.98.48.102'
          3        SEND_VAL                                                 <array>
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function ipcidrcheck:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 41
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 41
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 19
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 40
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 40
Branch analysis from position: 38
Branch analysis from position: 40
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
filename:       /in/clEqo
function name:  ipCidrCheck
number of ops:  44
compiled vars:  !0 = $IP, !1 = $CIDRArray, !2 = $CIDR, !3 = $net, !4 = $mask, !5 = $ip_net, !6 = $ip_mask, !7 = $ip_ip, !8 = $ip_ip_net
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2      > FE_RESET_R                                       $9      !1, ->41
          3    > > FE_FETCH_R                                               $9, !2, ->41
    6     4    >   INIT_FCALL                                               'preg_match'
          5        SEND_VAL                                                 '%23%2F%23'
          6        SEND_VAR                                                 !2
          7        DO_ICALL                                         $10     
          8      > JMPZ                                                     $10, ->19
    7     9    >   INIT_FCALL_BY_NAME                                       'split'
         10        SEND_VAL_EX                                              '%2F'
         11        SEND_VAR_EX                                              !2
         12        DO_FCALL                                      0  $11     
         13        FETCH_LIST_R                                     $12     $11, 0
         14        ASSIGN                                                   !3, $12
         15        FETCH_LIST_R                                     $14     $11, 1
         16        ASSIGN                                                   !4, $14
         17        FREE                                                     $11
         18      > JMP                                                      ->21
    9    19    >   ASSIGN                                                   !3, !2
   10    20        ASSIGN                                                   !4, 32
   14    21    >   INIT_FCALL                                               'ip2long'
         22        SEND_VAR                                                 !3
         23        DO_ICALL                                         $18     
         24        ASSIGN                                                   !5, $18
   15    25        SUB                                              ~20     32, !4
         26        SL                                               ~21     1, ~20
         27        SUB                                              ~22     ~21, 1
         28        BW_NOT                                           ~23     ~22
         29        ASSIGN                                                   !6, ~23
   17    30        INIT_FCALL                                               'ip2long'
         31        SEND_VAR                                                 !0
         32        DO_ICALL                                         $25     
         33        ASSIGN                                                   !7, $25
   19    34        BW_AND                                           ~27     !7, !6
         35        ASSIGN                                                   !8, ~27
   21    36        IS_EQUAL                                                 !8, !5
         37      > JMPZ                                                     ~29, ->40
   22    38    >   FE_FREE                                                  $9
         39      > RETURN                                                   <true>
    5    40    > > JMP                                                      ->3
         41    >   FE_FREE                                                  $9
   26    42      > RETURN                                                   <false>
   27    43*     > RETURN                                                   null

End of function ipcidrcheck

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.62 ms | 1394 KiB | 20 Q