You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+2-74Lines changed: 2 additions & 74 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,81 +29,9 @@ Monthly update is available for both IP2Location LITE and commercial database.
29
29
2.**Extensible.** If you require different granularity of IP information, you can visit [IP2Location.com](https://www.ip2location.com/databases) to download the relevant BIN file, and the information will made ready for you.
30
30
3.**Comprehensive Information.** There are more than 13 types of information that you can retrieve from an IP address. Please visit [IP2Location.com](https://www.ip2location.com/databases) for details.
31
31
32
-
## INSTALLATION
33
-
34
-
Install this package using **composer** as below:
35
-
36
-
```
37
-
composer require ip2location/ip2location-php
38
-
```
39
-
40
-
To test this installation, please browse examples/example.php using web browser.
41
-
42
-
## USAGE
43
-
44
-
You can check the **example.php** file to learn more about usage.
45
-
46
-
### Database Class
47
-
Below is the description of the functions available in the **Database** class.
48
-
49
-
| Function Name | Description |
50
-
|---|---|
51
-
|Constructor|Expect 2 input parameters:<ol><li>Full path of IP2Location BIN data file.</li><li>File Open Mode<ul><li> SHARED_MEMORY</li><li>MEMORY_CACHE</li><li>FILE_IO</li></ul></li></ol>For SHARED_MEMORY and MEMORY_CACHE, it will require your server to have sufficient memory to hold the BIN data, otherwise it will raise the errors during the object initialization.|
52
-
|**string** getDate()|Return the database's compilation date as a string of the form 'YYYY-MM-DD'|
53
-
|**string** getType()|Return the database's type, 1 to 26 respectively for DB1 to DB26. Please visit https://www.ip2location.com/databases for details.|
54
-
|**string** getModuleVersion()|Return the version of module|
55
-
|**string** getDatabaseVersion()|Return the version of database|
56
-
|**array** lookup($ip)|Return the IP information in array. Below is the information returned:<ul><li>ipNumber</li><li>ipVersion</li><li>ipAddress</li><li>countryCode</li><li>countryName</li><li>regionName</li><li>cityName</li><li>latitude</li><li>longitude</li><li>areaCode</li><li>iddCode</li><li>weatherStationCode</li><li>weatherStationName</li><li>mcc</li><li>mnc</li><li>mobileCarrierName</li><li>usageType</li><li>elevation</li><li>netSpeed</li><li>timeZone</li><li>zipCode</li><li>domainName</li><li>isp</li><li>addressType</li><li>category</li><li>district</li><li>asn</li><li>as</li></ul>You can visit [IP2Location](https://www.ip2location.com/databases/db26-ip-country-region-city-latitude-longitude-zipcode-timezone-isp-domain-netspeed-areacode-weather-mobile-elevation-usagetype-addresstype-category-district-asn) for the description of each field. Note: although the above names are not exactly matched with the names given in this link, but they are self-described.|
57
-
|**array** getCidr($ip)|Return an array of the complete IP list in CIDR format of the detected row record based on the given IP address.|
58
-
59
-
60
-
### WebService Class
61
-
Below is the description of the functions available in the **WebService** class.
| Constructor | Expect 3 input parameters:<ol><li>IP2Location API Key.</li><li>Package (WS1 - WS25)</li><li>Use HTTPS or HTTP</li></ol> |
66
-
| **array** lookup($ip) | Return the IP information in array.<ul><li>country_code</li><li>country_name</li><li>region_name</li><li>city_name</li><li>latitude</li><li>longitude</li><li>zip_code</li><li>time_zone</li><li>isp</li><li>domain</li><li>net_speed</li><li>idd_code</li><li>area_code</li><li>weather_station_code</li><li>weather_station_name</li><li>mcc</li><li>mnc</li><li>mobile_brand</li><li>elevation</li><li>usage_type</li><li>address_type</li><li>category</li><li>continent<ul><li>name</li><li>code</li><li>hemisphere</li><li>translations</li></ul></li><li>country<ul><li>name</li><li>alpha3_code</li><li>numeric_code</li><li>demonym</li><li>flag</li><li>capital</li><li>total_area</li><li>population</li><li>currency<ul><li>code</li><li>name</li><li>symbol</li></ul></li><li>language<ul><li>code</li><li>name</li></ul></li><li>idd_code</li><li>tld</li><li>translations</li></ul></li><li>region<ul><li>name</li><li>code</li><li>translations</li></ul></li><li>city<ul><li>name</li><li>translations</li></ul></li><li>geotargeting<ul><li>metro</li></ul></li><li>country_groupings</li><li>time_zone_info<ul><li>olson</li><li>current_time</li><li>gmt_offset</li><li>is_dst</li><li>sunrise</li><li>sunset</li></ul></li><ul> |
67
-
|**int** getCredit() | Return remaining credit of the web service account. |
68
-
69
-
### IpTools Class
70
-
71
-
Below is the description of the functions available in the **IpTools** class.
|**bool** isIpv4($ip) | Return either **true** or **false**. Verify if a string is a valid IPv4 address. |
76
-
|**bool** isIpv6($ip) | Return either **true** or **false**. Verify if a string is a valid IPv6 address. |
77
-
|**mixed** ipv4ToDecimal($ip) | Translate IPv4 address from dotted-decimal address to decimal format. Return **null** on error. |
78
-
|**mixed** decimalToIpv4($number) | Translate IPv4 address from decimal number to dotted-decimal address. Return **null** on error. |
79
-
|**mixed** ipv6ToDecimal($ip) | Translate IPv6 address from hexadecimal address to decimal format. Return **null** on error. |
80
-
|**mixed** decimalToIpv6($number) | Translate IPv6 address from decimal number into hexadecimal address. Return **null** on error. |
81
-
|**array** ipv4ToCidr($ipFrom, $ipTo) | Convert IPv4 range into a list of IPv4 CIDR notation. |
82
-
|**array** cidrToIpv4($cidr) | Convert IPv4 CIDR notation into a list of IPv4 addresses. |
83
-
|**array** ipv6ToCidr($ipFrom, $ipTo) | Convert IPv6 range into a list of IPv6 CIDR notation. |
84
-
|**array** cidrToIpv6($cidr) | Convert IPv6 CIDR notation into a list of IPv6 addresses. |
85
-
|**string** compressIpv6($ipv6) | Compress a IPv6 to shorten the length. |
86
-
|**string** expandIpv6($ipv6) | Expand a shorten IPv6 to full length. |
87
-
|**string** getVisitorIp() | Return the real IP address of the visitor. If an array of $ipData is supplied, it will return the list of IP address data found.|
88
-
89
-
### Country Class
90
-
91
-
Below is the description of the functions available in the **Country** class.
| Constructor | Expect a IP2Location Country Information CSV file. This database is free for download at https://www.ip2location.com/free/country-information|
96
-
|**array** getCountryInfo($countryCode) | Provide a ISO 3166 country code to get the country information in array. Will return a full list of countries information if country code not provided. Below is the information returned: <ul><li>country_code</li><li>country_alpha3_code</li><li>country_numeric_code</li><li>capital</li><li>country_demonym</li><li>total_area</li><li>population</li><li>idd_code</li><li>currency_code</li><li>currency_name</li><li>currency_symbol</li><li>lang_code</li><li>lang_name</li><li>cctld</li></ul> |
97
-
98
-
### Region Class
99
-
100
-
Below is the description of the functions available in the **Region** class.
| Constructor | Expect a IP2Location ISO 3166-2 Subdivision Code CSV file. This database is free for download at https://www.ip2location.com/free/iso3166-2|
105
-
|**string** getRegionCode($countryCode, $regionName) | Provide a ISO 3166 country code and the region name to get ISO 3166-2 subdivision code for the region. |
32
+
# Developer Documentation
106
33
34
+
To learn more about installation, usage, and code examples, please visit the developer documentation at [https://ip2location-php.readthedocs.io/en/latest/index.html](https://ip2location-php.readthedocs.io/en/latest/index.html).
0 commit comments