中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

php模擬post發(fā)送數(shù)據(jù)

2018-07-20    來(lái)源:open-open

容器云強(qiáng)勢(shì)上線!快速搭建集群,上萬(wàn)Linux鏡像隨意使用
<?PHP           
    $flag = 0;       
    //要post的數(shù)據(jù)        
$argv = array(       
     'var1'=>'abc',        
     'var2'=>'你好嗎');        
//構(gòu)造post字符串        
foreach ($argv as $key=>$value) {        
     if ($flag!=0) {       
             $params .= "&";        
             $flag = 1;        
     }        
     $params.= $key."="; $params.= urlencode($value);        
     $flag = 1;        
     }        
     $length = strlen($params);       
         //創(chuàng)建socket連接        
     $fp = fsockopen("127.0.0.1",80,$errno,$errstr,10) or exit($errstr."--->".$errno);        
     //構(gòu)造post請(qǐng)求的頭        
     $header = "POST /mobile/try.php HTTP/1.1";        
     $header .= "Host:127.0.0.1";        
     $header .= "Referer:/mobile/sendpost.php";        
     $header .= "Content-Type: application/x-www-form-urlencoded";        
     $header .= "Content-Length: ".$length."";        
     $header .= "Connection: Close";       
     //添加post的字符串        
     $header .= $params."";        
     //發(fā)送post的數(shù)據(jù)        
     fputs($fp,$header);        
     $inheader = 1;        
     while (!feof($fp)) {       
             $line = fgets($fp,1024); //去除請(qǐng)求包的頭只顯示頁(yè)面的返回?cái)?shù)據(jù)        
             if ($inheader && ($line == "n" || $line == "")) {       
                 $inheader = 0;        
             }        
             if ($inheader == 0) {        
                 echo $line;        
             }        
     }        
fclose($fp);        
?>

標(biāo)簽:

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請(qǐng)聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請(qǐng)與原作者聯(lián)系。

上一篇:C#性能測(cè)試模板和洗牌的隨機(jī)排序算法

下一篇:PHP四舍五入 保留幾位小數(shù) 格式化數(shù)字