PHP checks whether your browser has installed the alexa toolbar. This article introduces PHP to determine whether the alexa tool is installed in the User's browser. The principle is very simple. we only need to get the User-Agent character recognition, then, you can determine whether the alexa tool is installed in your browser. This article introduces PHP to determine whether your browser has installed the alexa tool. The principle is very simple. we only need to obtain the User-Agent character recognition, then you can check whether the alexa Toolbar is installed.
As we all know, the alexa Toolbar is a commonly used third-party statistical tool for websites. we usually customize the alexa toolbar to allow users to install it. you can click the toolbar content to improve the ranking of the website in alexa. For example, the alexa toolbar of Hebei News Network.
If we need to force user installation in some necessary php applications, this involves the judgment on whether the alexa Toolbar is installed or not. When a browser accesses a webpage, php can obtain User-Agent characters. When a browser with the Alexa Toolbar is used to request a webpage, the User-Agent character will contain more alexa marks. With this feature, you can determine whether your browser has installed the ALEXA toolbar. Use PHP's $ _ SERVER ['http _ USER_AGENT '] to obtain the UA string information of the browser.The following is the code for PHP to determine whether the alexa tool is installed in your browser:
The code is as follows: |
|
If (! Preg_match ("# Toolbar # I", $ _ SERVER ['http _ USER_AGENT ']) {showmessage (L ('Alexa _ failure'), 'https: // www. bKjia. c0m', 8000 );} |
(Because the User-Agent characters in firefox and ie are different, Alexa Toolbar in firefox and My Toolbar in ie. Therefore, we only need to determine whether the recognition character contains a Toolbar)
Note: how to obtain the alexa toolbar information of IE9
According to the official Microsoft development blog, IE9 uses short User-Agent characters by default and does not append. NET or any other information generated by software or machines to UA strings. Therefore, if you want to obtain whether the IE9 user has installed the alexa toolbar, you must click"Compatibility View"(As shown in)
...