試圖爲CURL編寫init函數。但有錯誤警告:curl_setopt()期望參數2很長,給出的字符串爲
警告:curl_setopt()預計參數2長,串給出
代碼很簡單。
$config['CURLOPT_URL'] = "https://weburl/index.action";
$config['CURLOPT_VERBOSE'] = 0;
$config['CURLOPT_SSLVERSION'] = 3;
$config['CURLOPT_SSL_VERIFYPEER'] = FALSE;
$config['CURLOPT_SSL_VERIFYHOST'] = 2;
$config['CURLOPT_FOLLOWLOCATION'] = 0;
$tuCurl = curl_init();
foreach($this->config as $key => $val)
{
curl_setopt($tuCurl, $key, $val);
}
你嘗試過'curl_setopt_array'嗎? –
對於每個'$ config []'元素,刪除引號 - 即:'$ config [CURLOPT_URL] ='https://weburl.blah';' – RamRaider