Tools to calculate network subnet, prefix, mask, IP range in PHP

0.1.2 2016-06-25 08:31 UTC

This package is auto-updated.

Last update: 2020-06-23 01:14:02 UTC


#Network calculator in PHP

Build Status Coverage Status Dependency Status Latest Stable Version Total Downloads Latest Unstable Version License

During searching for good network calculator I couldn't find a good one written in PHP. That's why I've decided to write it using only bitmask operations and math.

#What can I calculate?

  • Network address
  • Broadcast address
  • CIDR prefix
  • First and last IP in the network
  • Number of possible hosts in the network

#How to use?

$networkCalculator = new NetworkCalculator(", "");

echo $networkCalculator->calculateNetworkAddress(); //
echo $networkCalculator->calculateBroadcastIp(); //
echo $networkCalculator->calculateNetworkMaskLength(); // 24

list($first, $last) = $networkCalculator->calculateIpRange();

echo $first; //
echo $last; //

echo $networkCalculator; // will print all the information in pretty way

#Found a bug?

Just make pull request or report issue