【发布时间】:2017-04-30 05:09:28
【问题描述】:
伙计们。我写了一小段代码来获取站点访问者的IP,所以想问一下,我应该把$ip放在哪里才能得到当前位置。
<?php
$ip = $_SERVER['REMOTE_ADDR'];
$details = json_decode(file_get_contents("https://freegeoip.net/json/{$ip}/github.com"));
echo $details->city;
?>
【问题讨论】: