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'));
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught ValueError: The supplied range exceeds the maximum array size: start=-2684091394 end=1610875649 in /in/9LoFN:23 Stack trace: #0 /in/9LoFN(23): range(1610875649, -2684091394) #1 /in/9LoFN(36): ipv4Breakout('96.4.3.0', '255.255.255.0') #2 {main} thrown in /in/9LoFN on line 23
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
56.53 ms | 401 KiB | 8 Q