可能重复:
php函数变量范围
有什么理由我不能在函数中推送这些变量吗?如果我这样做
//function scraping_for_text_2
for($i=0; $i<$l; $i++) {
echo "$contents[$i]";
echo "$fnamearray[$i].torrent";
}
它回响了正确的价值
但是当我有这样的功能时
function scraping_for_text_2($iUrl,$iText)
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $uploadurl);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_COOKIEFILE, 'cookies.txt');
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$curlresult = curl_exec($curl);
curl_close ($curl);
$data = array(
"description" => "testing",
"torrent" => "@$fnamearray[$i]",
"submit" => "Upload"
);
我得到这个通知:未定义的变量:fnamearray 注意:未定义的变量:我在