我是一個的n00b所以請這些愚蠢的問題承擔 - 我知道我的捲曲的命令工作,我可以做一個在一個時間,但是當我添加此陣列和對付它只是不工作。 我知道這是基礎知識,但我試圖尋找的東西,這看起來應該工作。當然,我錯了HELP,這是簡單的抓取與多個網站,但它無法
<?php
$proxy = '127.0.0.1:8118';
$proxy = explode(':', $proxy);
$site[] = "http://site1.com";
$site[] = "http://site2.com";
$site[] = "http://site3.com";
$site[] = "http://site4.com";
// $site[] = explode(':', $site[]);
$maxsites = count($site);
// echo $site[];
echo $maxsites;
$counter ='1';
echo $counter;
echo "site count ".$site[$counter];
while ( $counter <= 4);
{
echo "got to here";
$url = $site[$counter];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $site[$counter]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_setopt($ch, CURLOPT_PROXY, $proxy[0]);
curl_setopt($ch, CURLOPT_PROXYPORT, $proxy[1]);
curl_setopt($ch, CURLOPT_HEADER, 1);
$exec = curl_exec($ch);
echo curl_error($ch);
print_r(curl_getinfo($ch));
echo $exec;
$counter++;
}
?>
您已將'$ counter'的值定義爲字符串,但在條件檢查中將其作爲整數引用。 – 2013-02-26 00:48:59