PHP 中的代理服务器


Proxy server in php

我在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);
  ?>