Home > Backend Development > PHP Tutorial > PHP determines whether the user's browser has the Alexa toolbar program installed_PHP tutorial

PHP determines whether the user's browser has the Alexa toolbar program installed_PHP tutorial

WBOY
Release: 2016-07-13 10:48:55
Original
886 people have browsed it

This article will introduce you to PHP to determine whether the user's browser has the Alexa toolbar installed. The principle is very simple. We only need to identify the characters with the user's User-Agent, and then judge to know whether the user has the Alexa toolbar installed. .

As we all know, the Alexa toolbar is a commonly used third-party statistical tool for websites. Usually we customize the Alexa toolbar for users to install it, and improve the website’s ranking in Alexa through users’ clicks on the toolbar content. As shown in the picture below, the Alexa toolbar of Hebei News Network.

PHP determines whether the users browser has the Alexa toolbar program installed_PHP tutorial

If we need to force users to install some necessary PHP applications, this involves judging whether the Alexa toolbar is installed or not. When the browser accesses a web page, php can obtain the user's User-Agent identification character. When using a browser equipped with Alexa Toolbar to request a web page, the Alexa tag will appear in the User-Agent identification characters. You can use this feature to determine whether the user's browser has the ALEXA toolbar installed. Obtain the browser's UA string information through PHP's $_SERVER['HTTP_USER_AGENT']. The following is PHP code to determine whether the user's browser has the Alexa toolbar installed:

Note: How to obtain Alexa toolbar information in IE9
The code is as follows
 代码如下 复制代码
if(!preg_match("#Toolbar#i", $_SERVER['HTTP_USER_AGENT'])){                 showmessage(L('alexa_failure'), 'https://www.bKjia.c0m',8000);             }
Copy code
if(!preg_match("#Toolbar#i", $_SERVER['HTTP_USER_AGENT'])){

showmessage(L('alexa_failure'), 'https://www.bKjia.c0m',8000);       }

(

Since the User-Agent identification characters in firefox and IE browsers are different, it is Alexa Toolbar in firefox and My Toolbar in IE. So when we judge, we only need to judge the identification characters. It doesn’t matter whether Toolbar is included

) PHP determines whether the users browser has the Alexa toolbar program installed_PHP tutorial

Microsoft’s official development blog stated that IE9 uses shorter User-Agent identification characters by default and no longer appends .NET and any other information generated by software or machines to the UA string. So if we want to get whether the IE9 user has installed the Alexa toolbar, we must let the user click "

Compatibility View http://www.bkjia.com/PHPjc/632752.html
www.bkjia.com
true
http: //www.bkjia.com/PHPjc/632752.htmlTechArticleThis article introduces PHP to determine whether the user's browser has the Alexa toolbar program installed. The principle is very simple. We only need to obtain and The user User-Agent recognizes the characters and then makes a judgment to know the user...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template