今天是:
首 页信息查询网站SEO查询工具CSS编辑器建站素材
网海拾贝,电脑资讯,电脑快报,it资讯,网站建设资讯,教程基地
软件新闻
操作系统
Vista Winxp Win2003 Linux Windows综合
工具软件
系统工具 媒体工具 网络工具 杀毒软件 聊天
软件开发
C教程 C++ Java C# ASP.NET JSP PHP
数据库
Oracle MySQL DB2 SQL Server Sybase
安全
网络 病毒
办公应用
Word Excel Powerpoint Outlook 其他
平面设计
Photoshop Fireworks Coreldraw Flash Illustrator 3dsmax
网站运营
网站运营 网站优化 网站策划 策划书下载 建站心得 站长故事 网站盈利 网页制作 网页特效 建站素材 免费资源 QQ频道
  当前位置:首 页 >> 软件开发 >> PHP教程 >> php的curl实现get和post

php的curl实现get和post

  发布于2008-08-18 11:11 来源:网页教学网

php的curl实现get和post

类似于dreamhost这类主机服务商,是显示fopen的使用的。使用php的curl可以实现支持 FTP、FTPS、HTTP HTPPS SCP SFTP TFTP TELNET DICT FILE和LDAP。curl 支持SSL证书、HTTP POST、HTTP PUT 、FTP 上传,kerberos、基于HTT格式的上传、代理、cookie、用户+口令证明、文件传送恢复、http代理通道就最常用的来说,是基于http的 get和post方法。

代码实现:

1、http的get实现

以下是代码片段:
 $ch = curl_init("http://www.webjx.com/") ;
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true) ;
curl_setopt( $ch, CURLOPT_BINARYTRANSFER, true) ;
 $output = curl_exec( $ch) ;
 $fh = fopen("out.html", 'w') ;
fwrite( $fh,  $output) ;
fclose( $fh) ;

2、http的post实现

以下是代码片段:
//extract data from the post
extract( $_POST) ;  
//set POST variables
 $url = 'http://www.webjx.com/get-post.php' ;
 $fields = array(
                        'lname'=>urlencode( $last_name) ,
                        'fname'=>urlencode( $first_name) ,
                        'title'=>urlencode( $title) ,
                        'company'=>urlencode( $institution) ,
                        'age'=>urlencode( $age) ,
                        'email'=>urlencode( $email) ,
                        'phone'=>urlencode( $phone)
                );  
//url-ify the data for the POST
foreach( $fields as  $key=> $value) {  $fields_string .=  $key.'='. $value.'&' ; }
rtrim( $fields_string ,'&') ; 
//open connection
 $ch = curl_init() ; 
//set the url, number of POST vars, POST data
curl_setopt( $ch, CURLOPT_URL, $url) ;
curl_setopt( $ch, CURLOPT_POST,count( $fields)) ;
curl_setopt( $ch, CURLOPT_POSTFIELDS, $fields_string) ; 
//execute post
 $result = curl_exec( $ch) ; 
//close connection
curl_close( $ch) ;

php的curl实现get和post

 


中查找“php的curl实现get和post”更多相关内容

中查找“php的curl实现get和post”更多相关内容



上一篇:Perl操作mysql数据库的方法
下一篇:php使用curl模拟用户登陆
最近更新 赞助商
·PHP单件模式结合命令链模式10-31
·取消网页缓存的html,asp,php代码10-28
·php时间比较函数DateDiff10-28
·php left函数 解决中文被截成乱码的问题10-28
·PHP上传类源码 瑞意上传类 RUpload10-28
·Windows Server 2008系统IIS7中PHP环境的..10-21
·PHP开发的Myers 订单跟踪系统 (MOTS)09-18
·php教程:php设计模式介绍之适配器模式08-22
·php使用curl模拟用户登陆08-21
·php的curl实现get和post08-18
·Perl操作mysql数据库的方法08-18

共有评论 0 条 网友评分 0分 查看所有评论


发表评论→ 学而不思则罔,思而不学则殆,请大胆发表你的见解。

输验证码:

您对此篇文章的评分:1分 2分 3分 4分 5分

  • 站内搜索
关键词

搜索方式

搜索范围

精确匹配
Baidu
网站首页 - 关于本站 - 网站地图 - 广告合作 - 站点声明 - RSS订阅 - 联系我们
Copyright © 2005 网海拾贝.[新ICP备05003216号]. All Rights Reserved .