最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

功能強(qiáng)大的PHP POST提交數(shù)據(jù)類(lèi)

 更新時(shí)間:2016年07月15日 11:21:14   投稿:lijiao  
這篇文章主要為大家詳細(xì)介紹了功能強(qiáng)大的PHP POST提交數(shù)據(jù)類(lèi),代碼簡(jiǎn)潔且具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了PHP功能強(qiáng)大的 POST提交數(shù)據(jù)類(lèi),供大家參考,具體內(nèi)容如下

<?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;

  }

}

?>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

共和县| 来安县| 南漳县| 富阳市| 察雅县| 宁夏| 汉阴县| 定远县| 兴义市| 德格县| 雅安市| 寻乌县| 四川省| 日照市| 邵阳市| 海安县| 阳高县| 镇雄县| 定安县| 常熟市| 前郭尔| 曲靖市| 金华市| 教育| 班戈县| 临邑县| 固原市| 德清县| 台北市| 宁安市| 北流市| 新和县| 凤城市| 保靖县| 桃园县| 仪征市| 和硕县| 宜兰市| 西青区| 辽宁省| 淮安市|