zoukankan      html  css  js  c++  java
  • put提交

    <?php
     
    function curlrequest($url,$data,$method='post'){
        $ch = curl_init(); //初始化CURL句柄 
        curl_setopt($ch, CURLOPT_URL, $url); //设置请求的URL
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); //设为TRUE把curl_exec()结果转化为字串,而不是直接输出 
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); //设置请求方式
         
        curl_setopt($ch,CURLOPT_HTTPHEADER,array("X-HTTP-Method-Override: $method"));//设置HTTP头信息
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);//设置提交的字符串
        $document = curl_exec($ch);//执行预定义的CURL 
        if(!curl_errno($ch)){ 
          $info = curl_getinfo($ch); 
          echo 'Took ' . $info['total_time'] . ' seconds to send a request to ' . $info['url']; 
        } else { 
          echo 'Curl error: ' . curl_error($ch); 
        }
        curl_close($ch);
         
        return $document;
    }
     
    $url = 'http://localhost/test/curl.php';
    $data = "request from put method";
    $return = curlrequest($url, $data, 'put');
     
    var_dump($return);exit;
    ?>
    
    <?php
    $arguments = file_get_contents('php://input');
    print_r($arguments);
    
    
  • 相关阅读:
    cmd命令之set详解
    微信公众号之推送消息
    总结js(1)
    本地文件夹变远程仓库并且提交Github
    npm之使用淘宝源
    页面倒计时返回
    在线sass编译器
    js条件语句之职责链数组
    【轉】靜
    css 實現微信聊天類似的氣泡
  • 原文地址:https://www.cnblogs.com/oneboi/p/7477384.html
Copyright © 2011-2022 走看看