PHP使用file_get_content设置头信息的方法
发布时间:2020-12-12 21:20:23 所属栏目:PHP教程 来源:网络整理
导读:本篇章节讲解PHP使用file_get_content设置头信息的方法。供大家参考研究具体如下: 直接上代码: array('header' => "Accept: application/jsonrn" . "Accept-Encoding: gzip,deflatern" . "Accept-Language: zh-cn,en;q=0.3rn" . "Accept-E
本篇章节讲解PHP使用file_get_content设置头信息的方法。分享给大家供大家参考,具体如下: 直接上代码: array('header' =>
"Accept: application/jsonrn" .
"Accept-Encoding: gzip,deflatern" .
"Accept-Language: zh-cn,en;q=0.3rn" .
"Accept-Encoding: gzip,deflatern" .
"Connection: keep-alivern" .
"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=4kacoqfe4ae33km3h0l2imjfd6rn" .
"Host: m.120ask.comrn" .
"Referer: http://m.120ask.com/health/show?page=2&id=84882&type=17rn" .
"User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:21.0) Gecko/20100101 Firefox/21.0rn" .
"X-Requested-With: XMLHttpRequest",'timeout'=>2
),);
$context = stream_context_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',$context);
更多关于PHP相关内容感兴趣的读者可查看本站专题:《》、《》及《》 希望本文所述对大家PHP程序设计有所帮助。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |