How to set header information in PHP

Source: Internet
Author: User
This article mainly introduces how to set up the header information PHP, interested in the reference of friends, I hope to be helpful to everyone.

The code is as follows:

<?php/**accept application/jsonaccept-encoding gzip, deflateaccept-language zh-cn,zh;q=0.8,en-us;q=0.5,en;q= 0.3Connection Keep-alivecookie 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=4kacoqfe4ae33km3h0l2imjfd6host M.120ask.comreferer http://m.120ask.com/health/show?page=2&id=84882 &type=17user-agent mozilla/5.0 (Windows NT 6.1; rv:21.0) gecko/20100101 Firefox/21.0x-requested-with   XMLHttpRequest */$hdrs = array (' http ' =>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_context_create ($hdrs);//mode 1//$fp = fopen ("H Ttp://m.120ask.com/health/show?page=2&id=84882&type=17 ", ' R ', false, $context);//Fpassthru ($FP);//Fclose ( $FP);//Mode 2//echo file_get_contents (' http://m.120ask.com/health/show?page=2&id=84882&type=17 ', 0, $context );

Summary : The above is the entire content of this article, I hope to be able to help you learn.

Related recommendations:

A method of set broken processing of keywords in text content by PHP

Methods for implementing error-Prompt return values in the RESTful API in PHP

The method of drawing Website Login homepage Image verification code based on PHP

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.