日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

解析curl提交GET,POST,Cookie的簡(jiǎn)單方法_PHP教程

編輯Tag賺U幣
教程Tag:暫無(wú)Tag,歡迎添加,賺取U幣!

推薦:解析PHP中empty is_null和isset的測(cè)試
代碼如下: 復(fù)制代碼 代碼如下: ?php $a; $b = false; $c = ''; $d = 0; $e = null; $f = array(); 首先是empty的var_dump輸出: boolean true boolean true boolean true boolean true boolean true boolean true 然后是is_null的輸出: boolean true boolean false bool

本篇文章是對(duì)curl提交GET,POST,Cookie的簡(jiǎn)單方法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下   復(fù)制代碼 代碼如下:


<?php
$get_data = array (
"get1"=> "get1",
"get2" => "get2",
"get3" => "get3"
);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://test.test.com/test.php?'.http_build_query($get_data));
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11');
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
$post_data = array (
"p1" => "test1",
"p2" => "test2",
"p3" => "test3"
);
curl_setopt($curl, CURLOPT_POST, true);
//["CONTENT_TYPE"]=> string(70) "multipart/form-data; boundary=------077a996f5afe"
//要發(fā)送文件,在文件名前面加上@前綴并使用完整路徑。
//使用數(shù)組提供post數(shù)據(jù)時(shí),CURL組件大概是為了兼容@filename這種上傳文件的寫法,默認(rèn)把content_type設(shè)為了multipart/form-data。
//雖然對(duì)于大多數(shù)web服務(wù)器并沒有影響,但是還是有少部分服務(wù)器不兼容。
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
//["CONTENT_TYPE"]=> string(33) "application/x-www-form-urlencoded"
//curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post_data));
//在沒有需要上傳文件的情況下,盡量對(duì)post提交的數(shù)據(jù)進(jìn)行http_build_query,然后發(fā)送出去,能實(shí)現(xiàn)更好的兼容性,更小的請(qǐng)求數(shù)據(jù)包。
$cookies = array(
'c1'=>'v1',
'c2'=>'v2',
'c3'=>'v3',
);
$cookies_string = '';
foreach($cookies as $name=>$value){
$cookies_string .= $name.'='.$value.';';
}
curl_setopt($curl, CURLOPT_COOKIE, $cookies_string);
$result = curl_exec($curl);
curl_close($curl);
var_dump($result);
exit;

分享:php selectradio和checkbox默認(rèn)選擇的實(shí)現(xiàn)方法詳解
本篇文章是對(duì)php selectradio和checkbox默認(rèn)選擇的實(shí)現(xiàn)方法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下 這是擴(kuò)展yibing的select默認(rèn)選擇的實(shí)現(xiàn)方法 復(fù)制代碼 代碼如下: select name=wuyeleixing size=1 option ?php if($myrow[wuyeleixing]==1) echo(selected);? value=1住

來(lái)源:模板無(wú)憂//所屬分類:PHP教程/更新時(shí)間:2013-07-01
相關(guān)PHP教程