A. 請問php高手一個關於curl的問題
$szUrl = "url";
$UserAgent = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; .NET CLR 3.5.21022; .NET CLR 1.0.3705; .NET CLR 1.1.4322)';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $szUrl);
curl_setopt($curl, CURLOPT_HEADER, 0); //0表示不輸出Header,1表示輸出
curl_setopt($curl, CURLOPT_USERAGENT, $UserAgent);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,TRUE);
$data = curl_exec($curl);
echo htmlx($data);
function htmlx($str){ $str = str_replace(">", str_replace(' ','',"& gt;"), $str);
$str = str_replace("<", str_replace(' ','',"& lt;"), $str);
$str = str_replace("\"", str_replace(' ','',"& quot;"), $str);
$str = str_replace(" ", str_replace(' ','',"& nbsp;"), $str);return $str;}
exit();