• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

PHP使用file_get_content设置头信息的方法_php技巧

php 搞代码 3年前 (2022-01-26) 35次浏览 已收录 0个评论

本文实例讲述了PHP使用file_get_content设置头信息的方法。分享给大家供大家参考,具体如下:

直接上代码:

array('header' =>    "Accept: application/json\r\n" .   "Accept-Encoding: gzip, deflate\r\n" .   "Accept-Language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3\r\n" .   "Accept-Encoding: gzip, deflate\r\n" .   "Connection: keep-alive\r\n" .   "Cookie: mzys_is_frist_access=1; mzys_c_uuid=guest_215cbc0979b5bd2; mzys_access20130610=1; mzys_qz_uuid=d6d4640f93cb7a4; CNZZDATA30040410=cnzz_eid%3D1008690174-1370849811-http%253A%252F%252Fm.120ask.com%26ntime%3D1370855345%26cnzz_a%3D43%26retime%3D1370855484258%26sin%3D%26ltime%3D1370855484258%26rtime%3D0; PHPSESSID=4kacoqfe4ae33km3h0l2imjfd6\r\n" .   "Host: m.120ask.com\r\n" .   "Referer: http://m.120ask.com/health/show?page=2&id=84882&type=17\r\n" .   "User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:21.0) Gecko/20100101 Firefox/21.0\r\n" .   "X-Requested-With: XMLHttpRequest",   'timeout'=>2  ),);$context = stream_conte<a>@本文9来源gao($daima.com搞@代@#码8网^</a><strong>搞代gaodaima码</strong>xt_create($hdrs);//方式1// $fp = fopen("http://m.120ask.com/health/show?page=2&id=84882&type=17", 'r', false, $context);// fpassthru($fp);// fclose($fp);//方式2//echo file_get_contents('http://m.120ask.com/health/show?page=2&id=84882&type=17', 0, $context);

希望本文所述对大家PHP程序设计有所帮助。


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:PHP使用file_get_content设置头信息的方法_php技巧
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址