PHP code example of rpodwika / network-calculator

1. Go to this page and download the library: Download rpodwika/network-calculator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rpodwika / network-calculator example snippets


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

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

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

echo $first; // 192.168.1.1
echo $last; // 192.168.1.254

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