1. Go to this page and download the library: Download gwk/ip_address 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/ */
gwk / ip_address example snippets
php
use IPAddress\IPv4\Address;
use IPAddress\IPv4\Subnet;
$address = new Address("1.2.8.200"); // These statements yield the same address
$address = new Address(0x010208c8);
$address = new Address(array(1, 2, 8, 200));
$address = new Address(array("1", "2", "010", "0xc8"));
$subnet = new Subnet("1.2.3.4", "255.255.0.0"); // These statements yield the same subnet
$subnet = Subnet::fromCidr("1.2.3.4", 16);
$subnet = Subnet::fromString("1.2.3.4 255.255.0.0");
$subnet = Subnet::fromString("1.2.3.4/16");
if($address->isPrivate()) {
echo "Your address is in one of the RFC1918 Private networks.\n";
}
if($subnet->match($address)) {
echo "I know your address is in the \"$subnet\" subnet.\n";
// OUTPUT: I know your address is in the "1.2.3.4 netmask 255.255.0.0" subnet.
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.