PHP uses File_get_content to set header information, phpgetfilecontent_php tutorial

Source: Internet
Author: User
Tags php error

PHP uses File_get_content to set header information, phpgetfilecontent


This example describes how PHP uses File_get_content to set header information. Share to everyone for your reference, as follows:

Directly on the code:

<?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 );

Read more about PHP related content readers can view the topic: "PHP Basic Grammar Introductory Tutorial", "PHP error and Exception handling method summary" and "PHP common functions and Skills summary"

I hope this article is helpful to you in PHP programming.

Articles you may be interested in:

    • PHP file_get_contents function Crawl HTTPS Address error resolution method (two methods)
    • PHP file_get_contents function Read Remote data timeout workaround
    • Example of using file_get_contents post data code in PHP
    • PHP using file_get_contents Crawl Web page Chinese garbled problem solving method
    • How PHP uses file_get_contents to read large files
    • Comparison and analysis of file_get_contents and curl performance in PHP
    • File_get_contents High-level usage examples in PHP
    • Usage comparison of three functions of curl, Fsocket and file_get_content in PHP
    • PHP file_get_contents Setting Timeout processing method
    • Example of using the PHP stream_context_create () function
    • PHP stream_context_create () function and usage analysis
    • PHP breaks through Http_referer-based anti-theft chain measures (stream_context_create)

http://www.bkjia.com/PHPjc/1099059.html www.bkjia.com true http://www.bkjia.com/PHPjc/1099059.html techarticle PHP uses File_get_content to set header information, Phpgetfilecontent This example describes how PHP uses File_get_content to set header information. Share to everyone for your reference, specific ...

  • 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.