Home > Backend Development > PHP Tutorial > Ubuntu 12.04 装配php curl

Ubuntu 12.04 装配php curl

WBOY
Release: 2016-06-13 11:16:51
Original
1113 people have browsed it

Ubuntu 12.04 安装php curl

安装php curl

sudo apt-get install php5-curl
Copy after login

重启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";
??? ?>

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template