PHP code example of ip2location / ip2proxy-codeigniter4

1. Go to this page and download the library: Download ip2location/ip2proxy-codeigniter4 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/ */

    

ip2location / ip2proxy-codeigniter4 example snippets


    // (optional) Define IP2Proxy database path.
    define('IP2PROXY_DATABASE', '/path/to/ip2proxy/database');

    $ipx = new IP2Proxy_lib();
    $countryCode = $ipx->getCountryShort('1.0.241.135');

    $countryShort = $ipx->getCountryShort($ip);
    $countryLong = $ipx->getCountryLong($ip);
    $region = $ipx->getRegion($ip);
    $city = $ipx->getCity($ip);
    $isp = $ipx->getISP($ip);
    $doamin = $ipx->getDomain($ip);
    $usageType = $ipx->getUsageType($ip);
    $proxyType = $ipx->getProxyType($ip);
    $asn = $ipx->getASN($ip);
    $as = $ipx->getAS($ip);
    $lastSeen = $ipx->getLastSeen($ip);
    $threat = $ipx->getThreat($ip);
    $provider = $ipx->getProvider($ip);
    $isProxy = $ipx->isProxy($ip);

    // (ine('IP2PROXY_API_KEY', 'your_api_key');

    // ( Define to use https or http.
    define('IP2PROXY_USESSL', false);

    $ipx = new IP2Proxy_lib();
    print_r ($ipx->getWebService('1.0.241.135'));

	// (define('IP2LOCATION_IO_API_KEY', 'your_api_key');

    // (optional) Define Translation information. Refer to https://www.ip2location.io/ip2location-documentation for available languages.
    define('IP2LOCATION_IO_LANGUAGE', 'zh-cn');

    $ipl = new IP2Proxy_lib();
    print_r ($ipl->getWebService('1.0.241.135'));

    define('IP2PROXY_DATABASE_TABLE', 'ip2proxy_table_name');

    $db = model('IP2Proxy_model', false);
    print_r ($db->lookup('1.0.241.135'));