How does PHP get the browser type?

Source: Internet
Author: User
PHP How to get access to the page browser type, including client and browser type

Reply content:

PHP How to get access to the page browser type, including client and browser type

There are ready-made open source projects on GitHub that you can refer to below:
For example: This browser project in Cbschuld supports the following browsers:

Opera Browser::browser_opera
WebTV BROWSER::BROWSER_WEBTV netpositive browser::browser_netpositive
Internet Explorer Browser::browser_ie Pocket Internet Explorer
Browser::browser_pocket_ie Galeon Browser::browser_galeon Konqueror
Browser::browser_konqueror ICab Browser::browser_icab OmniWeb
Browser::browser_omniweb Phoenix Browser::browser_phoenix Firebird
Browser::browser_firebird Firefox Browser::browser_firefox Mozilla
Browser::browser_mozilla Amaya Browser::browser_amaya Lynx
Browser::browser_lynx Safari Browser::browser_safari IPhone
Browser::browser_iphone iPod browser::browser_ipod Google ' s Android
Browser::browser_android Google ' s Chrome browser::browser_chrome
GoogleBot Browser::browser_googlebot Yahoo! ' s slurp
Browser::browser_slurp ' s Validator browser::browser_w3cvalidator
BlackBerry Browser::browser_blackberry

print_r($_SERVER['HTTP_USER_AGENT']);

PHP has a $_SERVER['HTTP_USER_AGENT'] browser and operating system to obtain information, such as on my own e-commerce output is:

mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) applewebkit/537.36 (khtml, like Gecko) chrome/43.0.2357.124 safari/537.36

From this, we can analyze the current user's browser kernel, browser version and operating system and other information

Differentiate mobile devices and PCs from accessing sites

You can try the PHP self-bring function
Get_browser (NULL);
Returns similar

Array(    [browser_name_regex] => ^mozilla/5\.0 (windows; .; windows nt 5\.1; .*rv:.*) gecko/.* firefox/0\.9.*$    [browser_name_pattern] => Mozilla/5.0 (Windows; ?; Windows NT 5.1; *rv:*) Gecko/* Firefox/0.9*    [parent] => Firefox 0.9    [platform] => WinXP    [browser] => Firefox    [version] => 0.9    [majorver] => 0    [minorver] => 9    [cssversion] => 2    [frames] => 1    [iframes] => 1    [tables] => 1    [cookies] => 1    [backgroundsounds] =>    [vbscript] =>    [javascript] => 1    [javaapplets] => 1    [activexcontrols] =>    [cdf] =>    [aol] =>    [beta] => 1    [win16] =>    [crawler] =>    [stripper] =>    [wap] =>    [netclr] =>)

Use the Get_browser () Reference manual link

$browser = get_browser(null, true);print_r($browser);
  • 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.