PHP code example of outsanity / ip-analysis

1. Go to this page and download the library: Download outsanity/ip-analysis 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/ */

    

outsanity / ip-analysis example snippets




utsanity\IpAnalysis\IpAnalysis;

$ip = new IpAnalysis('127.0.0.1');
echo 'documentation: ' . ($ip->isDocumentation()  ? 'yes' : 'no') . "\n"; // 192.0.2.65, 2001:db8:1:3::2
echo 'global: ' .        ($ip->isGlobal()         ? 'yes' : 'no') . "\n"; // 8.8.8.8, 2001:4860:4860::8888
echo 'loopback: ' .      ($ip->isLoopback()       ? 'yes' : 'no') . "\n"; // 127.0.0.1, ::1
echo 'multicast: ' .     ($ip->isMulticast()      ? 'yes' : 'no') . "\n"; // 224.0.1.1, ff00::101
echo 'private: ' .       ($ip->isPrivateNetwork() ? 'yes' : 'no') . "\n"; // 10.0.0.1, 192.168.0.1, fd11:1111:1111::1
echo 'subnet: ' .        ($ip->isLocalNetwork()   ? 'yes' : 'no') . "\n"; // 169.254.0.1, fe80::6450:6a14:93ba:de09