3v4l.org

run code in 300+ PHP versions simultaneously
<?php function cidr_match($ip, $range){ list ($subnet, $bits) = explode('/', $range); if ($bits === null) { $bits = 32; } $ip = ip2long($ip); $subnet = ip2long($subnet); $mask = -1 << (32 - $bits); $subnet &= $mask; # nb: in case the supplied subnet wasn't correctly aligned return ($ip & $mask) == $subnet; } var_dump(cidr_match('79.142.17.1', '79.142.16.0/20')); var_dump(cidr_match('79.142.35.4', '79.142.16.0/20'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NKRFP
function name:  (null)
number of ops:  15
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'cidr_match'
          2        SEND_VAL                                                 '79.142.17.1'
          3        SEND_VAL                                                 '79.142.16.0%2F20'
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
   16     7        INIT_FCALL                                               'var_dump'
          8        INIT_FCALL                                               'cidr_match'
          9        SEND_VAL                                                 '79.142.35.4'
         10        SEND_VAL                                                 '79.142.16.0%2F20'
         11        DO_FCALL                                      0  $2      
         12        SEND_VAR                                                 $2
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

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

End of function cidr_match

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.61 ms | 1009 KiB | 18 Q