简体   繁体   English

在codeigniter中找到IP地址

[英]find ip address in codeigniter

I tried to add geolocation on my site so i will get customer current location for that i want ip address which i did not get. 我试图在我的网站上添加地理位置,因此我将获得客户想要的我想要的IP地址的当前位置。

<?php include('doctype.php');?>
<header>
  <?php include('topHeader.php');?>
  <?php include('searchArea.php');?>

</header>
<?php include('nav.php');?>
<div class="container">
  <section>
<?php  
$b=get_client_ip();
echo $b;
function get_client_ip() {
    $ipaddress = '';
     if($_SERVER['REMOTE_ADDR'])
        $ipaddress = $_SERVER['REMOTE_ADDR'];
    else
        $ipaddress = 'UNKNOWN';
    return $ipaddress;
}?>
  </section>
</div>
<?php include('footer.php');?>

this is my code i tried to get ip address for geolocation. 这是我的代码,我试图获取用于地理位置的IP地址。 did you know any geolaction example to get customer current city. 您是否知道任何通过地理信息获取客户当前城市的示例。

Best way of get current location using geolocation 使用地理位置获取当前位置的最佳方法

Use below get the client current location Latitude & Longitude 在下面使用以获取客户当前位置的经度和纬度

<!DOCTYPE html>
<html>
<body onload="getlocation()">

<script>

function getlocation() {
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(showPosition);
    } else { 
        alert("Geolocation is not supported by this browser.");
    }
}

function showPosition(position) {
   alert("Latitude: " + position.coords.latitude + 
    "\n Longitude: " + position.coords.longitude);  
}
</script>

</body>
</html>

This latitude and longitude based display google map marker 此基于纬度和经度的显示Google地图标记

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM