久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      PHP之使用cURL實(shí)現(xiàn)Get和Post請(qǐng)求

      PHP之使用cURL實(shí)現(xiàn)Get和Post請(qǐng)求

      先來看一下在PHP中建立cURL請(qǐng)求的基本步驟:

       ?。?)初始化

          curl_init()

       ?。?)設(shè)置變量

          curl_setopt() 。最為重要。有一長串cURL參數(shù)可供設(shè)置,它們能指定URL請(qǐng)求的各個(gè)細(xì)節(jié)。要一次性全部看完并理解可能比較困難,所以今天我們只試一下那些更常用也更有用的選項(xiàng)。

       ?。?)執(zhí)行并獲取結(jié)果

          curl_exec()

        (4)釋放cURL句柄

          curl_close()

      下面就看一下具體的實(shí)現(xiàn):

      1.Post方式實(shí)現(xiàn)(模擬Post請(qǐng)求,調(diào)用接口)

      <?php $url = "http://192.168.147.131/index.php/addUser";//你要請(qǐng)求的地址 $post_data = array(   "uid" => "1111",   "username" => "lunar",   "nickname" => "吾獨(dú)望月", ); $ch = curl_init();//初始化cURL   curl_setopt($ch,CURLOPT_URL,$url);//抓取指定網(wǎng)頁 curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);//要求結(jié)果為字符串并輸出到屏幕上 curl_setopt($ch,CURLOPT_POST,1);//Post請(qǐng)求方式 curl_setopt($ch,CURLOPT_POSTFIELDS,$post_data);//Post變量   $output = curl_exec($ch);//執(zhí)行并獲得HTML內(nèi)容 curl_close($ch);//釋放cURL句柄   print_r($output);

      2.Get方式實(shí)現(xiàn)

      <?php $url = "http://www.cnblogs.com/blogforly/";//你要請(qǐng)求的地址   $ch = curl_init();//初始化cURL   curl_setopt($ch,CURLOPT_URL,$url);//抓取指定網(wǎng)頁 curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);//要求結(jié)果為字符串并輸出到屏幕上 curl_setopt($ch, CURLOPT_HEADER, 0);//設(shè)置header   $output = curl_exec($ch);//執(zhí)行并獲得HTML內(nèi)容 curl_close($ch);//釋放cURL句柄   print_r($output);

      相關(guān)學(xué)習(xí)推薦:PHP編程從入門到精通

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)