Whose head is the best? Header information about PHP

Source: Internet
Author: User
Header information is important, 2 people, one called server (service side), one called browser (client), that is, there are 2 header information, request header information and return header information.

Then if the header information is obtained through PHP, the server wants to get the header information of the browser request, can use $_server, the code is as follows:

 
  $value) {$headers [$name] = $value;      }      return $headers;  } Var_dump (Getheaderinfo ());? >

Output:

Array (size=32) ' http_host ' + string ' localhost ' (length=9) ' http_user_agent ' + = String ' mozilla/5.0 (Windows NT 5.1; rv:20.0) gecko/20100101 firefox/20.0 ' (length=65) ' http_accept ' = = String ' Text/html,application/xhtml+xml, application/xml;q=0.9,*/*;q=0.8 ' (length=63) ' http_accept_language ' = = String ' zh-cn,zh;q=0.8,en-us;q=0.5,en;q= 0.3 ' (length=35) ' http_accept_encoding ' + string ' gzip, deflate ' (length=13) ' http_cookie ' = = String ' Bdshare_fir stime=1365907820098 ' (length=30) ' http_connection ' + string ' keep-alive ' (length=10) ' http_cache_control ' = = str ing ' max-age=0 ' (length=9) ' PATH ' = = String ' C:\WINDOWS\system32; C:\WINDOWS; c:\windows\system32\wbem;d:\svn\bin;d:\curl\curl-7.19.5; E:\mysql5.5\mysql\bin; C:\Program files\mysql\mysql Server 5.5\bin; C:\Ruby193\bin; C:\Program Files\sinovoice\jtts 5.0 desktop\bin;d:\php\xampp\php; C:\wamp\bin\php\php5.4.3\php.exe; '  (length=266) ' SystemRoot ' = "string ' C:\WINDOWS ' (length=10) ' COMSPEC '" = StrinG ' C:\WINDOWS\system32\cmd.exe ' (length=27) ' pathext ' = = String '. COM;. EXE;. BAT;. CMD;. VBS;. VBE;. JS;. JSE;. WSF;. WSH ' (length=48) ' windir ' + String ' C:\WINDOWS ' (length=10) ' server_signature ' = ' = String ' (length=0) ' server_s Oftware ' = = String ' apache/2.2.22 (Win32) php/5.4.3 ' (length=31) ' server_name ' = = String ' localhost ' (length=9) ' S Erver_addr ' = ' = String ' 127.0.0.1 ' (length=9) ' server_port ' = ' + String ' (length=2) ' remote_addr ' = = String ' 1 27.0.0.1 ' (length=9) ' document_root ' + string ' c:/wamp/www/' (length=12) ' server_admin ' = = String ' Admin@localhos T ' (length=15) ' script_filename ' = = String ' c:/wamp/www/1.php ' (length=17) ' remote_port ' = = String ' 2483 ' (length= 4) ' gateway_interface ' = = String ' cgi/1.1 ' (length=7) ' server_protocol ' = = String ' http/1.1 ' (length=8) ' Request_ METHOD ' = ' + string ' GET ' (length=3) ' query_string ' = ' + String ' (length=0) ' request_uri ' = = String '/1.php ' (len gth=6) ' script_name ' = StriNg '/1.php ' (length=6) ' php_self ' = = String '/1.php ' (length=6) ' request_time_float ' = FLOAT 1366034246.187 ' REQ Uest_time ' = = int 1366034246

You can see not only some information about the output client, but also some information on the server. For this information specific role, here is not more, please see http://www.cnblogs.com/IAmBetter/archive/2013/04/11/3014796.html

In fact, for the Apache server can use out-of-the-box functions: Getallheaders (), with the benefits of this function is not much to say, directly look at the return value

Array (size=8)  ' Host ' = = String ' localhost ' (length=9)  ' user-agent ' + = String ' mozilla/5.0 (Windows NT 5.1; rv:20.0) gecko/20100101 firefox/20.0 ' (length=65)  ' Accept ' = = String ' Text/html,application/xhtml+xml, application/xml;q=0.9,*/*;q=0.8 ' (length=63)  ' accept-language ' = = String ' zh-cn,zh;q=0.8,en-us;q=0.5,en;q= 0.3 ' (length=35)  ' accept-encoding ' + string ' gzip, deflate ' (length=13)  ' Cookie ' = ' = String ' bdshare_ firstime=1365907820098 ' (length=30)  ' Connection ' = String ' keep-alive ' (length=10)  ' cache-control ' = String ' max-age=0 ' (length=9)

There is no such parameter as HTTP_, and there is a need to deal with such problems.

Knowing how to get the header information from the request, you should also know how to set the header information, such as:

 
  

The client gets the header information for the server setting [name]

So what's the use of this? Actually have to judge what the other party is the request? Is it a synchronous request or an asynchronous request?

2.html page is the request page

 
  

Back to Page

 
  

Results:

Finished, said not good everyone forgive.

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