- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- //设置URL,可以放入curl_init参数中
- curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) ApplewebKit/535.1 (Khtml, like Gecko) Chrome/14.0.835.202 Safari/535.1");
- //设置UA
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- //将curl_exec()获取的信息以文件流的形式返回,而不是直接输出。 如果不加,即使没有echo,也会自动输出
- $content = curl_exec($ch);
- //执行
- curl_close($ch);
- //关闭
- echo $content;
- //该片段来自于http://www.codesnippet.cn/detail/170120131708.html
来源: http://www.codesnippet.cn/detail/170120131708.html