Skip to content

Commit e4df311

Browse files
committed
Updated README.md.
1 parent f2b83ad commit e4df311

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

README.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,16 @@ Sample codes are given in this project, under **controllers** folder. You may ru
3030

3131
### BIN Database
3232
Use following codes in your application for get geolocation information.
33-
33+
```
3434
// (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.
3535
define('IP2LOCATION_DATABASE', '/path/to/ip2location/database');
3636
3737
$ipl = new IP2Location_lib();
3838
$countryCode = $ipl->getCountryCode('8.8.8.8');
39+
```
3940

4041
Below are the methods supported for BIN data file lookup.
41-
42+
```
4243
$countryCode = $ipl->getCountryCode($ip);
4344
$countryName = $ipl->getCountryName($ip);
4445
$regionName = $ipl->getRegionName($ip);
@@ -61,10 +62,11 @@ Below are the methods supported for BIN data file lookup.
6162
$usageType = $ipl->getUsageType($ip);
6263
$addressType = $ipl->getAddressType($ip);
6364
$category = $ipl->getCategory($ip);
65+
```
6466

6567
### Web Service
6668
Use following codes in your application for get geolocation information.
67-
69+
```
6870
// (required) Define IP2Location API key.
6971
define('IP2LOCATION_API_KEY', 'your_api_key');
7072
@@ -82,6 +84,25 @@ Use following codes in your application for get geolocation information.
8284
8385
$ipl = new IP2Location_lib();
8486
print_r ($ipl->getWebService('8.8.8.8'));
87+
```
88+
89+
### IPTools
90+
Use following codes in your application for get IPTools class information.
91+
```
92+
$ipl = new IP2Location_lib();
93+
var_dump($ipl->isIpv4('8.8.8.8'));echo '<br>';
94+
var_dump($ipl->isIpv6('2001:4860:4860::8888'));echo '<br>';
95+
print_r($ipl->ipv4ToDecimal('8.8.8.8'));echo '<br>';
96+
print_r($ipl->decimalToIpv4(134744072));echo '<br>';
97+
print_r($ipl->ipv6ToDecimal('2001:4860:4860::8888'));echo '<br>';
98+
print_r($ipl->decimalToIpv6('42541956123769884636017138956568135816'));echo '<br>';
99+
print_r($ipl->ipv4ToCidr('8.0.0.0', '8.255.255.255'));echo '<br>';
100+
print_r($ipl->cidrToIpv4('8.0.0.0/8'));echo '<br>';
101+
print_r($ipl->ipv6ToCidr('2002:0000:0000:1234:abcd:ffff:c0a8:0000', '2002:0000:0000:1234:ffff:ffff:ffff:ffff'));echo '<br>';
102+
print_r($ipl->cidrToIpv6('2002::1234:abcd:ffff:c0a8:101/64'));echo '<br>';
103+
print_r($ipl->compressIpv6('2002:0000:0000:1234:FFFF:FFFF:FFFF:FFFF'));echo '<br>';
104+
print_r($ipl->expandIpv6('2002::1234:FFFF:FFFF:FFFF:FFFF'));echo '<br>';
105+
```
85106

86107
## Dependencies
87108
This module requires IP2Location BIN data file or IP2Location API key to function. You may download the BIN data file at

0 commit comments

Comments
 (0)