PHP使用file_get_content设置头信息的方法
网络编程 2021-07-05 09:09www.168986.cn编程入门
这篇文章主要介绍了PHP使用file_get_content设置头信息的方法,结合实例形式对比分析了PHP使用fopen及file_get_contents设置及获取头信息的相关技巧,需要的朋友可以参考下
本文实例讲述了PHP使用file_get_content设置头信息的方法。分享给大家供大家参考,具体如下:
直接上代码:
<?php /** Aept application/json Aept-Encoding gzip, deflate Aept-Language zh-,zh;q=0.8,en-us;q=0.5,en;q=0.3 Connection keep-alive Cookie mzys_is_frist_aess=1; mzys_c_uuid=guest_215cbc0979b5bd2; mzys_aess20130610=1; mzys_qz_uuid=d6d4640f93cb7a4; CNZZDATA30040410=zz_eid%3D1008690174-1370849811-http%253A%252F%252Fm.120ask.%26ntime%3D1370855345%26zz_a%3D43%26retime%3D1370855484258%26sin%3D%26ltime%3D1370855484258%26rtime%3D0; PHPSESSID=4kacoqfe4ae33km3h0l2imjfd6 Host m.120ask. Referer http://m.120ask./health/show?page=2&id=84882&type=17 User-Agent Mozilla/5.0 (Windows NT 6.1; rv:21.0) Gecko/20100101 Firefox/21.0 X-Requested-With XMLHttpRequest */ $hdrs = array( 'http' =>array('header' => "Aept: application/json\r\n" . "Aept-Encoding: gzip, deflate\r\n" . "Aept-Language: zh-,zh;q=0.8,en-us;q=0.5,en;q=0.3\r\n" . "Aept-Encoding: gzip, deflate\r\n" . "Connection: keep-alive\r\n" . "Cookie: mzys_is_frist_aess=1; mzys_c_uuid=guest_215cbc0979b5bd2; mzys_aess20130610=1; mzys_qz_uuid=d6d4640f93cb7a4; CNZZDATA30040410=zz_eid%3D1008690174-1370849811-http%253A%252F%252Fm.120ask.%26ntime%3D1370855345%26zz_a%3D43%26retime%3D1370855484258%26sin%3D%26ltime%3D1370855484258%26rtime%3D0; PHPSESSID=4kacoqfe4ae33km3h0l2imjfd6\r\n" . "Host: m.120ask.\r\n" . "Referer: http://m.120ask./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_context_create($hdrs); //方式1 // $fp = fopen("http://m.120ask./health/show?page=2&id=84882&type=17", 'r', false, $context); // fpassthru($fp); // fclose($fp); //方式2 //echo file_get_contents('http://m.120ask./health/show?page=2&id=84882&type=17', 0, $context);
更多关于PHP相关内容感兴趣的读者可查看本站专题:《》、《》及《》
希望本文所述对大家PHP程序设计有所帮助。
编程语言
- 机械手焊接机器人编程 机械手焊接设备编程
- vb数据库编程实例,vb做数据库
- tiobe世界编程语言排行榜,全球编程语言排行
- 成都java编程培训 成都it编程培训中心
- 编程基础培训,编程基础知识培训
- flash游戏编程基础教程,flash游戏开发教程
- 不会英语能学编程吗 不会英语可以学程序员吗
- 爱心代码编程C语言 爱心代码编程c语言公式
- c语言编程学习入门 c语言编程快速入门
- 西门子plc编程培训 西门子plc编程培训班
- 哪里可以学编程 台州哪里可以学编程
- 少儿编程哪个好 少儿编程哪个品牌好
- 编程是什么意思,图形编程是什么意思
- c语言编程软件下载,c语言编程软件在哪下载
- java编程软件下载,java编程下载手机版
- ug编程培训学校,ug编程培训教程