From e4df311437e9cf20805021f5ff792225d907651a Mon Sep 17 00:00:00 2001 From: IP2Location Date: Mon, 4 Jul 2022 16:51:54 +0800 Subject: [PATCH] Updated README.md. --- README.md | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ac53f3c..1c3898b 100644 --- a/README.md +++ b/README.md @@ -30,15 +30,16 @@ Sample codes are given in this project, under **controllers** folder. You may ru ### BIN Database Use following codes in your application for get geolocation information. - +``` // (optional) Define IP2Location database path. By default, the IP2LOCATION_DATABASE is pointed to *application/libraries/ip2location/IP2LOCATION-DB.BIN* if you choose not to change the original settings. define('IP2LOCATION_DATABASE', '/path/to/ip2location/database'); $ipl = new IP2Location_lib(); $countryCode = $ipl->getCountryCode('8.8.8.8'); +``` Below are the methods supported for BIN data file lookup. - +``` $countryCode = $ipl->getCountryCode($ip); $countryName = $ipl->getCountryName($ip); $regionName = $ipl->getRegionName($ip); @@ -61,10 +62,11 @@ Below are the methods supported for BIN data file lookup. $usageType = $ipl->getUsageType($ip); $addressType = $ipl->getAddressType($ip); $category = $ipl->getCategory($ip); +``` ### Web Service Use following codes in your application for get geolocation information. - +``` // (required) Define IP2Location API key. define('IP2LOCATION_API_KEY', 'your_api_key'); @@ -82,6 +84,25 @@ Use following codes in your application for get geolocation information. $ipl = new IP2Location_lib(); print_r ($ipl->getWebService('8.8.8.8')); +``` + +### IPTools +Use following codes in your application for get IPTools class information. +``` + $ipl = new IP2Location_lib(); + var_dump($ipl->isIpv4('8.8.8.8'));echo '
'; + var_dump($ipl->isIpv6('2001:4860:4860::8888'));echo '
'; + print_r($ipl->ipv4ToDecimal('8.8.8.8'));echo '
'; + print_r($ipl->decimalToIpv4(134744072));echo '
'; + print_r($ipl->ipv6ToDecimal('2001:4860:4860::8888'));echo '
'; + print_r($ipl->decimalToIpv6('42541956123769884636017138956568135816'));echo '
'; + print_r($ipl->ipv4ToCidr('8.0.0.0', '8.255.255.255'));echo '
'; + print_r($ipl->cidrToIpv4('8.0.0.0/8'));echo '
'; + print_r($ipl->ipv6ToCidr('2002:0000:0000:1234:abcd:ffff:c0a8:0000', '2002:0000:0000:1234:ffff:ffff:ffff:ffff'));echo '
'; + print_r($ipl->cidrToIpv6('2002::1234:abcd:ffff:c0a8:101/64'));echo '
'; + print_r($ipl->compressIpv6('2002:0000:0000:1234:FFFF:FFFF:FFFF:FFFF'));echo '
'; + print_r($ipl->expandIpv6('2002::1234:FFFF:FFFF:FFFF:FFFF'));echo '
'; +``` ## Dependencies This module requires IP2Location BIN data file or IP2Location API key to function. You may download the BIN data file at