国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > PHP > 正文

功能強大的PHP POST提交數據類

2024-05-04 23:48:09
字體:
來源:轉載
供稿:網友

本文實例為大家分享了PHP功能強大的 POST提交數據類,供大家參考,具體內容如下

 

<?php class Request{  public static function post($url, $post_data = '', $timeout = 5){//curl    $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url);    curl_setopt ($ch, CURLOPT_POST, 1);    if($post_data != ''){      curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);    }    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);     curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);    curl_setopt($ch, CURLOPT_HEADER, false); $file_contents = curl_exec($ch);    curl_close($ch);    return $file_contents;  }  public static function post2($url, $data){//file_get_content    $postdata = http_build_query(      $data    );    $opts = array('http' =>           array(             'method' => 'POST',             'header' => 'Content-type: application/x-www-form-urlencoded',             'content' => $postdata           )    );    $context = stream_context_create($opts);    $result = file_get_contents($url, false, $context);    return $result;  } public static function post3($host,$path,$query,$others=''){//fsocket    $post="POST $path HTTP/1.1/r/nHost: $host/r/n";    $post.="Content-type: application/x-www-form-";    $post.="urlencoded/r/n${others}";    $post.="User-Agent: Mozilla 4.0/r/nContent-length: ";    $post.=strlen($query)."/r/nConnection: close/r/n/r/n$query";    $h=fsockopen($host,80);    fwrite($h,$post);    for($a=0,$r='';!$a;){        $b=fread($h,8192);         $r.=$b;        $a=(($b=='')?1:0);       }    fclose($h);    return $r;  }}?>

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VeVb武林網。


注:相關教程知識閱讀請移步到PHP教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 车致| 静乐县| 彩票| 客服| 阳城县| 渝北区| 周至县| 锡林郭勒盟| 社会| 新郑市| 玛纳斯县| 武川县| 客服| 石门县| 兴山县| 永嘉县| 松原市| 唐海县| 南充市| 鄂伦春自治旗| 图片| 大港区| 布尔津县| 铁岭市| 微山县| 紫金县| 军事| 华坪县| 格尔木市| 泊头市| 夏河县| 湾仔区| 恩施市| 永清县| 沙洋县| 革吉县| 新营市| 比如县| 革吉县| 桐柏县| 遂昌县|