【发布时间】:2015-01-23 01:07:30
【问题描述】:
我在 Firefox 中使用代理服务器扩展来更改我的 IP 地址。
php中是否有任何脚本可以更改IP地址?我在 php 中只发现了域更改脚本,但没有发现与 ip 相关的脚本。请有任何建议。
【问题讨论】:
我在 Firefox 中使用代理服务器扩展来更改我的 IP 地址。
php中是否有任何脚本可以更改IP地址?我在 php 中只发现了域更改脚本,但没有发现与 ip 相关的脚本。请有任何建议。
【问题讨论】:
使用 curl,你可以做到这一点...试试下面的一个:
<?php
$proxy = "xx.xx.xx.xx:xx";
$proxy = explode(':', $proxy);
$url = "http://www.google.com";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXY, $proxy[0]);
curl_setopt($ch, CURLOPT_PROXYPORT, $proxy[1]);
curl_setopt($ch, CURLOPT_HEADER, 1);
$exec = curl_exec($ch);
?>
【讨论】:
$proxy 我输入我的代理IP 地址然后我运行脚本。要检查 IP 地址,我输入了$_SERVER['SERVER_ADDR'],它显示我的 IP 而不是代理。