This example describes how PHP uses File_get_content to set header information. Share to everyone for your reference, specific as follows:
Directly on the code:
<?php/** Accept Application/json accept-encoding gzip, deflate Accept-language zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3 Connection keep-alive 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 Host m.120ask.com Referer http://m.120ask.com/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 ' => ' 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 ("http://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);
More interested in PHP related content readers can view the site topics: "Introduction to PHP Basic Grammar", "PHP error and Exception handling method summary" and "PHP common functions and Skills summary"
I hope this article will help you with the PHP program design.