色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

實現獲取http內容的php函數分享

復制代碼 代碼如下:
<?php
function http_open($url, $data, $cookie = null, $method = "GET", $timeout = 60) {
 $options = array();
 $options['http']['method'] = $method;
 $options['http']['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
 $options['http']['timeout'] = $timeout;
 if($method == "POST") :
  $length = strlen($data);
  $options['http']['header'] = "Content-type: application/x-www-form-urlencoded/r/n".
  "Content-Length: {$length}/r/n".
  "P3P: CP=/"CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR/"/r/n".
  "cookie: {$cookie}/r/n".
  "Connection: close/r/n";
  $options['http']['content'] = $data;
 else:
  $options['http']['header'] = "Content-type: application/x-www-form-urlencoded/r/n".
  "P3P: CP=/"CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR/"/r/n".
  "cookie: {$cookie}/r/n".
  "Connection: close/r/n";
 endif;

 $context = stream_context_create($options);
 return file_get_contents($url, 0, $context);
}
echo http_open("http://localhost/1.php", "username=haowei", "id=5", "POST");

php技術實現獲取http內容的php函數分享,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 莱州市| 且末县| 化州市| 孟州市| 历史| 民丰县| 天长市| 宝山区| 绥化市| 遵义市| 利川市| 厦门市| 临城县| 新郑市| 应用必备| 沂南县| 乌苏市| 苏尼特左旗| 吴川市| 南召县| 东方市| 长垣县| 新宁县| 阜南县| 淮北市| 巴里| 陆良县| 呼图壁县| 海口市| 绍兴县| 木里| 新野县| 江川县| 扬州市| 竹北市| 阿拉善右旗| 刚察县| 阳曲县| 丰城市| 广水市| 安庆市|