To use this site in PHP, you can create a function, like the following:
function getLocationUsingIP($ip) {
$result = @json_decode(file_get_contents(
"http://www.geoplugin.net/json.gp?ip=" . $ip));
if($result && $result->geoplugin_countryName != null)
{
$location['region'] = $result->geoplugin_region;
$location['city'] = $result->geoplugin_city;
$location['country'] = $result->geoplugin_countryCode;
$location['latitute'] = $result->geoplugin_latitude;
$location['longitude'] = $result->geoplugin_longitude;
}
return $location;
}
To call it, call the function by passing the IP address of the user (obtainable via $_SERVER[REMOTE_ADDR]):
$location = getLocationUsingIP($_SERVER[REMOTE_ADDR]);
echo $location['region'] . "<br/>";
echo $location['city'] . "<br/>";
echo $location['country'] . "<br/>";
echo $location['latitute'] . "<br/>";
echo $location['longitude'] . "<br/>";
To learn more about PHP and MySQL programming, enrol in the WEB103 - Web Development using PHP and MySQL course (2-days).
Course Fee
S$1097 (nett; no GST)
If your company is sponsoring you for the training, your company can enjoy 400% tax deductions/ allowances and/or 60% cash payout for investment in innovation and productivity improvements under the Productivity and Innovation Credit (PIC) scheme. For more details, check out the Productivity and Innovation Credit page.
Schedules
Start Date | End Date | Details | Category |
---|---|---|---|
Tue Feb 03 2015 | Wed Feb 04 2015 | ||
Thu Mar 05 2015 | Fri Mar 06 2015 | ||
Mon Apr 06 2015 | Tue Apr 07 2015 |
Venue
Bayview Hotel Singapore
30 Bencoolen Street
Singapore 189621
30 Bencoolen Street
Singapore 189621
No comments:
Post a Comment