WeChat public Platform Message Interface Development (31) WeChat browser http_user_agent judgment _php Tutorial

Source: Internet
Author: User
Tags http authentication http digest authentication
Public Platform developer public Platform developer Public platform Development Mode browser Http_user_agent
Author:Square Double Studio
Original:Http://www.cnblogs.com/txw1958/archive/2013/05/25/weixin-if31-http_user_agent.html

In the development of the public platform, we sometimes need to develop the Web page and determine whether it is from the browser access, this article describes how to make this decision.

One,$_server array

$_SERVERis an array of information such as header information (header), path, and script location (scripts locations), and so on. The items in this array are created by the WEB server. There is no guarantee that each server will provide all the items, the server may ignore some, or provide some items that are not listed here.

In $_SERVER , you may be able, perhaps not, to find these elements below. Note that if you run PHP as a command line, the elements listed below are almost no valid (or meaningless).

'PHP_SELF'
The
file name of the current execution script, which is related to document root. For example, the use of the address in http://example.com/test.php/foo.bar the script $_SERVER['PHP_SELF'] will be obtained /test.php/foo.bar . The __FILE__ constant contains the full path and file name of the current (for example, the containing) file. starting with PHP 4.3.0, if PHP is running in command-line mode, this variable will contain the script name. Previous versions of this variable are not available.
' argv '
The
array of arguments passed to the script. When the script runs as a command line, the ARGV variable is passed to the program's C-language style command-line arguments. When called by a GET method, the variable contains a query string.
' ARGC '
contains the number of arguments that are passed to the script in command-line mode, if run in command-line mode.
'GATEWAY_INTERFACE'
The
version of the CGI specification used by the server; for example, " cgi/1.1".
'SERVER_ADDR'
The
IP address of the server where the script is currently running.
'SERVER_NAME'
the host name of the server where the script is currently running. If the script is running on a virtual host, the name is determined by the value set by that virtual host.
'SERVER_SOFTWARE'
The
server identification string, given in the header information in response to the request.
'SERVER_PROTOCOL'
the name and version of the communication protocol when the page is requested. For example, "http/1.0".
'REQUEST_METHOD'
access the request method used by the page; for example, " GET", " HEAD", " POST", " PUT"
'REQUEST_TIME'
timestamp at the start of the request. Available from PHP 5.1.0.
'REQUEST_TIME_FLOAT'
the timestamp at the start of the request, and the microsecond level of accuracy. Starting from PHP 5.4.0.
'QUERY_STRING'
Query string
, if any, for page access.
'DOCUMENT_ROOT'
the document root directory where the script is currently running. Defined in the server configuration file.
'HTTP_ACCEPT'
Accept: The contents of the item, if any, in the current request header.
'HTTP_ACCEPT_CHARSET'
Accept-charset in the current request header : the contents of the item, if one exists. For example: " iso-8859-1,*,utf-8".
'HTTP_ACCEPT_ENCODING'
accept-encoding in the current request header : the contents of the item, if one exists. For example: " gzip".
'HTTP_ACCEPT_LANGUAGE'
Accept-language in the current request header : the contents of the item, if one exists. For example: " en".
'HTTP_CONNECTION'
Connection in the current request header : the contents of the item, if one exists. For example: " keep-alive".
'HTTP_HOST'
Host in current request header : the contents of the item, if one exists.
'HTTP_REFERER'
The
address, if any, that directs the user's agent to the previous page of the current page. Determined by the user agent settings. Not all user agents will set the item, and some will also provide the ability to modify it HTTP_REFERER . In short, the value is not trustworthy.
'HTTP_USER_AGENT'
User-agent in the current request header : the contents of the item, if one exists. The string indicates the information of the user agent accessing the page. A typical example is:mozilla/4.5 [en] (X11; U Linux 2.2.9 i586).
'HTTPS'
if the script is accessed through the HTTPS protocol, it is set to a non-null value.
'REMOTE_ADDR'
the IP address of the user who browsed the current page.
'REMOTE_HOST'
the host name of the user who browsed the current page. DNS reverse resolution is not dependent on the user REMOTE_ADDR .
'REMOTE_PORT'
the port number used by the user's machine to connect to the WEB server.
'REMOTE_USER'
Validated
users
'REDIRECT_REMOTE_USER'
authenticates the user if the request has been redirected internally.
'SCRIPT_FILENAME'

The absolute path of the current execution script

'SERVER_ADMIN'
This value indicates the Server_admin parameter in the Apache server configuration file. If the script is running on a virtual host, the value is the value of that virtual host.
'SERVER_PORT'
the port used by the WEB server. The default value is "+". If SSL secured connection is used, this value is the HTTP port set by the user.
'SERVER_SIGNATURE'
A string that contains the server version and the virtual host name.
'PATH_TRANSLATED'
the base path of the file system (not the document root) where the current script resides. This is the result of the server making a virtual-to-real-path image.
'SCRIPT_NAME'
contains the path to the current script. This is useful when the page needs to point to itself. The __FILE__ constant contains the full path and file name of the current script, such as the containing file.
'REQUEST_URI'
The URI is used to specify the page to be accessed. For example, " /index.html".
'PHP_AUTH_DIGEST'
when running as an Apache module, this variable is set to the "Authorization" HTTP header content sent by the client (for further authentication operations) during HTTP Digest authentication.
'PHP_AUTH_USER'
when PHP is running in Apache or IIS (PHP 5 is an ISAPI) module, and the HTTP authentication feature is being used, this variable is the user name entered by the user.
'PHP_AUTH_PW'
when PHP is running in Apache or IIS (PHP 5 is an ISAPI) module, and the HTTP authentication feature is being used, this variable is the password that the user entered.
'AUTH_TYPE'
This variable is the type of authentication when PHP is running in the Apache module mode and is using the HTTP authentication feature.
'PATH_INFO'
contains the path information provided by the client, followed by the real script name and before the query string, if present. For example, if the current script is accessed through a URL http://www.example.com/php/path_info.php/some/stuff?foo=bar , it $_SERVER['PATH_INFO'] will contain /some/stuff.
'ORIG_PATH_INFO'
The
PATH_INFO original version of "" before being processed by PHP.

Ii. acquisition of Http_user_agent

The following methods can be obtained

 
  < span="">< span="">["Http_user_agent"< span="">?>

Under the iphone, return

< span="">/4.3.2

Under Android, go back

< span="">/4.5.255

As you can see, < span=""> The browser is followed by its version number.
At the same time, you can also determine whether the phone type is iphone or Android

Third, Judge browser access

We judge whether there are micromessenger in Http_user_agent

=============================================================

Welcome to the Double studio, to learn about our industry and the latest developments

http://www.bkjia.com/PHPjc/440338.html www.bkjia.com true http://www.bkjia.com/PHPjc/440338.html techarticle Public Platform developer public Platform developer Public platform Development Mode browser Http_user_agent Author: Fang Times Studio Original: http://www.cnblogs.com/txw195 ...

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