【发布时间】:2015-09-07 23:38:04
【问题描述】:
我需要浏览器的客户端(客户)IP地址。
这是php中的客户端页面
<?php
$xml_request = '<XMLRequest>
<RequestType>ServiceRequest</RequestType>
<RequestLogin>test</RequestLogin>
</XMLRequest>';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://testserver.com/test_xml/request.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_ENCODING,'gzip');
curl_setopt($ch, CURLOPT_POST, true );
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_request);
echo curl_exec($ch); curl_close($ch);
?>
这是我的服务器页面
'http://testserver.com/test_xml/request.php' 在 php 中
$service_request = file_get_contents('php://input');
echo 'Client IP Address: '. $_SERVER['REMOTE_ADDR'];
但这里是“ECHO”我自己的服务器 IP。
我如何将客户端浏览器 IP 获取到我的服务器
【问题讨论】:
-
是不是因为你是在与服务器相同的 PC 上测试,所以客户端和服务器都在同一个 IP 地址上??