PHP curl_setopt()函数实例代码与参数分析

2019-04-09 06:39:58于丽


if($querystring != '')
{
$url = $url . "?" . $querystring;
}

$ch = curl_init();
$timeout = 60; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$handles = curl_exec($ch);
//下面是替换,可以结合服务器伪静态设置
$handles = preg_replace("/?page=([0-9]+)&categoryId=([0-9]+)/i","/fenlei/category-$1-$2.html",$handles);
$handles = preg_replace("/?categoryId=([0-9]+)/i","/fenlei/category--$1.html",$handles);
$handles = preg_replace("/?page=([0-9]+)/i","/fenlei/category-$1.html",$handles);
$handles = preg_replace("/infodetail.aspx?ID=([0-9]+)/i","/fenlei/$1.html",$handles);
$handles = str_replace("infolist.aspx","/fenlei/index.html",$handles);
$handles = str_replace("unionlist.aspx","unionlist.html",$handles);
echo $handles;
?>
相关文章 大家在看