首頁 >後端開發 >php教程 >Ubuntu 12.04 装配php curl

Ubuntu 12.04 装配php curl

WBOY
WBOY原創
2016-06-13 11:16:511106瀏覽

Ubuntu 12.04 安装php curl

安装php curl

sudo apt-get install php5-curl

重启apache服务器

?

测试代码:

??? echo "Hello";
??? $ch = curl_init("http://www.google.com");
??? $timeout = 60;
??? curl_setopt($ch, CURLOPT_URL, "http://www.google.com");
? curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
? curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0
(compatible; MSIE 6.0; Windows NT 5.1; SV1)");
? curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
? $contents = curl_exec($ch);
??? curl_close($ch);
??? var_dump($contents);
??? echo "end";
??? ?>

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn