您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

实现获取http内容的php函数分享_PHP教程

2025/8/25 16:05:40发布11次查看
复制代码 代码如下:
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);
http://www.bkjia.com/phpjc/825244.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/825244.htmltecharticle复制代码 代码如下: ?php function http_open($url, $data, $cookie = null, $method = get, $timeout = 60) { $options = array(); $options['http']['method'] = $method; $options...
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product