国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

PHP的curl實(shí)現(xiàn)get和post

瀏覽:4日期:2024-02-23 08:53:46

類似于dreamhost這類主機(jī)服務(wù)商,是顯示fopen的使用的。使用php的curl可以實(shí)現(xiàn)支持FTP、FTPS、HTTP HTPPS SCP SFTP TFTP TELNET DICT FILE和LDAP。curl 支持SSL證書、HTTP POST、HTTP PUT 、FTP 上傳,kerberos、基于HTT格式的上傳、代理、cookie、用戶+口令證明、文件傳送恢復(fù)、http代理通道就最常用的來說,是基于http的get和post方法。

代碼實(shí)現(xiàn):

1、http的get實(shí)現(xiàn)

$ch = curl_init('http://www.devdao.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實(shí)現(xiàn)

//extract data from the postextract($_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 POSTforeach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&' ; }rtrim($fields_string ,'&') ;//open connection$ch = curl_init() ;//set the url, number of POST vars, POST datacurl_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 connectioncurl_close($ch) ;

標(biāo)簽: PHP
主站蜘蛛池模板: 三都| 郁南县| 南昌市| 靖江市| 平谷区| 和林格尔县| 英德市| 闵行区| 富锦市| 揭东县| 柳州市| 抚宁县| 湘西| 巫山县| 洛南县| 凤凰县| 九台市| 疏附县| 额尔古纳市| 广丰县| 如皋市| 琼海市| 安吉县| 枝江市| 磴口县| 新龙县| 永春县| 五常市| 北宁市| 大埔区| 河北区| 平昌县| 依兰县| 石家庄市| 沧源| 怀安县| 宁明县| 上林县| 易门县| 庆安县| 九江市|