3v4l.org

run code in 300+ PHP versions simultaneously
<?php function ipv4Breakout ($ip_address, $ip_nmask) { $hosts = array(); //convert ip addresses to long form $ip_address_long = ip2long($ip_address); $ip_nmask_long = ip2long($ip_nmask); //caculate network address $ip_net = $ip_address_long & $ip_nmask_long; //caculate first usable address $ip_host_first = ((~$ip_nmask_long) & $ip_address_long); $ip_first = ($ip_address_long ^ $ip_host_first) + 1; //caculate last usable address $ip_broadcast_invert = ~$ip_nmask_long; $ip_last = ($ip_address_long | $ip_broadcast_invert) - 1; //caculate broadcast address $ip_broadcast = $ip_address_long | $ip_broadcast_invert; foreach (range($ip_first, $ip_last) as $ip) { array_push($hosts, $ip); } $block_info = array(array("network" => "$ip_net"), array("first_host" => "$ip_first"), array("last_host" => "$ip_last"), array("broadcast" => "$ip_broadcast"), $hosts); return $block_info; } print_r(ipv4Breakout ('96.4.3.0', '255.255.255.0'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9LoFN
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   INIT_FCALL                                               'print_r'
          1        INIT_FCALL                                               'ipv4breakout'
          2        SEND_VAL                                                 '96.4.3.0'
          3        SEND_VAL                                                 '255.255.255.0'
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function ipv4breakout:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 31, Position 2 = 37
Branch analysis from position: 31
2 jumps found. (Code = 78) Position 1 = 32, Position 2 = 37
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
filename:       /in/9LoFN
function name:  ipv4Breakout
number of ops:  54
compiled vars:  !0 = $ip_address, !1 = $ip_nmask, !2 = $hosts, !3 = $ip_address_long, !4 = $ip_nmask_long, !5 = $ip_net, !6 = $ip_host_first, !7 = $ip_first, !8 = $ip_broadcast_invert, !9 = $ip_last, !10 = $ip_broadcast, !11 = $ip, !12 = $block_info
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        ASSIGN                                                   !2, <array>
    6     3        INIT_FCALL                                               'ip2long'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $14     
          6        ASSIGN                                                   !3, $14
    7     7        INIT_FCALL                                               'ip2long'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                         $16     
         10        ASSIGN                                                   !4, $16
   10    11        BW_AND                                           ~18     !3, !4
         12        ASSIGN                                                   !5, ~18
   13    13        BW_NOT                                           ~20     !4
         14        BW_AND                                           ~21     !3, ~20
         15        ASSIGN                                                   !6, ~21
   14    16        BW_XOR                                           ~23     !3, !6
         17        ADD                                              ~24     ~23, 1
         18        ASSIGN                                                   !7, ~24
   17    19        BW_NOT                                           ~26     !4
         20        ASSIGN                                                   !8, ~26
   18    21        BW_OR                                            ~28     !3, !8
         22        SUB                                              ~29     ~28, 1
         23        ASSIGN                                                   !9, ~29
   21    24        BW_OR                                            ~31     !3, !8
         25        ASSIGN                                                   !10, ~31
   23    26        INIT_FCALL                                               'range'
         27        SEND_VAR                                                 !7
         28        SEND_VAR                                                 !9
         29        DO_ICALL                                         $33     
         30      > FE_RESET_R                                       $34     $33, ->37
         31    > > FE_FETCH_R                                               $34, !11, ->37
   24    32    >   INIT_FCALL                                               'array_push'
         33        SEND_REF                                                 !2
         34        SEND_VAR                                                 !11
         35        DO_ICALL                                                 
   23    36      > JMP                                                      ->31
         37    >   FE_FREE                                                  $34
   27    38        CAST                                          6  ~36     !5
         39        INIT_ARRAY                                       ~37     ~36, 'network'
         40        INIT_ARRAY                                       ~38     ~37
   28    41        CAST                                          6  ~39     !7
         42        INIT_ARRAY                                       ~40     ~39, 'first_host'
         43        ADD_ARRAY_ELEMENT                                ~38     ~40
   29    44        CAST                                          6  ~41     !9
         45        INIT_ARRAY                                       ~42     ~41, 'last_host'
         46        ADD_ARRAY_ELEMENT                                ~38     ~42
   30    47        CAST                                          6  ~43     !10
         48        INIT_ARRAY                                       ~44     ~43, 'broadcast'
         49        ADD_ARRAY_ELEMENT                                ~38     ~44
   31    50        ADD_ARRAY_ELEMENT                                ~38     !2
   27    51        ASSIGN                                                   !12, ~38
   33    52      > RETURN                                                   !12
   34    53*     > RETURN                                                   null

End of function ipv4breakout

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.56 ms | 1403 KiB | 22 Q