如何知道代理在curlphp中是否正常工作
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_TIMEOUT, 0);
curl_setopt($ch, CURLOPT_PROXYPORT,8080);
curl_setopt($ch, CURLOPT_PROXYTYPE, 'HTTP');
curl_setopt($ch, CURLOPT_PROXY,'218.213.90.92');
$head = curl_exec($ch);
curl_close($ch);
答案 0 :(得分:0)
您可以将$url
设置为"https://soulogic.com/ip/"
如果返回::ffff:218.213.90.92
,则表示代理正在运行。
或者在服务器端,创建一个PHP文件:
<?php
echo $_SERVER["REMOTE_ADDR"];