php curl用法
发布:smiling 来源: PHP粉丝网 添加日期:2014-08-05 14:11:00 浏览: 评论:0
在php使用curl时必须先在php.ini中开启extension=php_curl.dll前面的;去了才行,curl是php中一款内置的浏览器,它可以模仿用户浏览信息进行网站浏览,等下面来看一实例,代码如下:
- function postpage($url)
 - {
 - $response = "";
 - $rd=rand(1,4);
 - $proxy='http://221.214.27.253:808';
 - if($rd==2) $proxy='http://222.77.14.56:8088';
 - if($rd==3) $proxy='http://202.98.123.126:8080';
 - if($rd==4) $proxy='http://60.14.97.38:8080';
 - if($url != "") {
 - $ch = curl_init($url);
 - curl_setopt($ch, curlopt_header, 0);
 - curl_setopt($ch, curlopt_returntransfer, true);
 - curl_setopt($ch, curlopt_proxy, $proxy);
 - $response = curl_exec($ch);
 - if(curl_errno($ch)) $response = "";
 - curl_close($ch);
 - }
 - return $response;
 - }
 
curl包括部份函数,如下所示:
- curl_close — close a curl session
 - curl_copy_handle — copy a curl handle along with all of its preferences
 - curl_errno — return the last error number
 - curl_error — return a string containing the last error for the current session
 - curl_exec — perform a curl session
 - curl_getinfo — get information regarding a specific transfer
 - curl_init — initialize a curl session
 - curl_multi_add_handle — add a normal curl handle to a curl multi handle
 - curl_multi_close — close a set of curl handles
 - curl_multi_exec — run the sub-connections of the current curl handle
 - curl_multi_getcontent — return the content of a curl handle if curlopt_returntransfer is set
 - curl_multi_info_read — get information about the current transfers
 - curl_multi_init — returns a new curl multi handle
 - curl_multi_remove_handle — remove a multi handle from a set of curl handles
 - curl_multi_select — wait for activity on any curl_multi connection
 - curl_setopt_array — set multiple options for a curl transfer
 - curl_setopt — set an option for a curl transfer
 - curl_version — gets curl version information
 
Tags: php curl用法
- 上一篇:php ereg_replace函数
 - 下一篇:php 获取客户浏览器与操作系统类型
 
相关文章
- ·PHP校验ISBN码的函数(2013-11-11)
 - ·PHP不缓存数据头(2013-11-11)
 - ·PHP采集程序中常用的函数(2013-11-11)
 - ·PHP多重判断删除文件函数(2013-11-11)
 - ·php中文汉字截取函数(2013-11-12)
 - ·如何用php创建与删除多级目录函数(2013-11-14)
 - ·什么函数能够把文件从一个目录下转移到另外一个目录下?(2013-11-27)
 - ·php_admin_value(php_admin_flag)和php_value(php_flag)(2013-11-27)
 - ·使用PHP重新实现PHP脚本引擎内置函数(2013-11-27)
 - ·计算一个程序的执行时间的函数(2013-11-27)
 - ·php curl_init函数用法(2013-11-28)
 - ·php md5 与md5_file区别详细说明(2013-11-28)
 - ·php session_cache_limiter session_cache_expire等函数(2013-11-29)
 - ·php var_dump简单测试(2013-11-29)
 - ·php file_exists无效解决办法(2013-11-29)
 - ·强大的php检查文件类型(2013-11-30)
 
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
 - PHP新手上路(一)(7)
 - 惹恼程序员的十件事(5)
 - PHP邮件发送例子,已测试成功(5)
 - 致初学者:PHP比ASP优秀的七个理由(4)
 - PHP会被淘汰吗?(4)
 - PHP新手上路(四)(4)
 - 如何去学习PHP?(2)
 - 简单入门级php分页代码(2)
 - php中邮箱email 电话等格式的验证(2)
 
