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

首頁(yè) > 開發(fā) > PHP > 正文

實(shí)現(xiàn)獲取http內(nèi)容的php函數(shù)分享

2024-05-04 23:21:20
字體:
供稿:網(wǎng)友

復(fù)制代碼 代碼如下:


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

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 湖南省| 光泽县| 安徽省| 柏乡县| 韶山市| 泰安市| 木兰县| 秦皇岛市| 油尖旺区| 芦山县| 闽清县| 班玛县| 阿鲁科尔沁旗| 集贤县| 措美县| 从化市| 犍为县| 禹州市| 青阳县| 海门市| 嘉荫县| 临西县| 赣榆县| 海原县| 财经| 宁陵县| 上饶县| 无为县| 深水埗区| 益阳市| 伊通| 大埔区| 肃宁县| 方正县| 自治县| 永春县| 方正县| 阿拉善盟| 句容市| 永和县| 延吉市|