Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 348379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:21:32+00:00 2026-05-12T11:21:32+00:00

I’ve searched for this and everything I find is way more than I need.

  • 0

I’ve searched for this and everything I find is way more than I need. I’ve done this in JavaScript before, but I would really prefer using PHP. How would I go about displaying a message to my visitors, depending on which browser they’re using?

Example:

IE User would see: “You’re using Internet Explorer”

Firefox User would see: “You’re using Mozilla Firefox”

I’m not exactly sure if there are other major browsers besides IE, Firefox, Chrome, Safari, and Opera. But I would at least want to have a message directed to each one of those browsers individually. Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T11:21:33+00:00Added an answer on May 12, 2026 at 11:21 am

    To identify the user’s browser server-side, you’ll have to parse the $_SERVER['HTTP_USER_AGENT'] variable…

    … Or, probably better, use the get_browser function — just note you’ll have to configure something in php.ini, or you’ll get this kind of warning :

    Warning: get_browser() [function.get-browser]: browscap ini directive not set
    

    Like the PHP manual page says :

    Note : In order for this to work, your browscap configuration setting in
    php.ini must point to the correct
    location of the browscap.ini file on
    your system. browscap.ini is not
    bundled with PHP, but you may find an
    up-to-date » php_browscap.ini
    file here.

    While browscap.ini contains
    information on many browsers, it
    relies on user updates to keep the
    database current. The format of the
    file is fairly self-explanatory.

    After downloading that file and adding this line to php.ini :

    browscap = /home/squale/developpement/tests/temp/php_browscap.ini
    

    The following portion of code :

    var_dump(get_browser(null, true));
    

    Gives me :

    array
      'browser_name_regex' => string '^mozilla/5\.0 (x11; .*linux.*; .*rv:1\.9.*) gecko/.*$' (length=53)
      'browser_name_pattern' => string 'Mozilla/5.0 (X11; *Linux*; *rv:1.9*) Gecko/*' (length=44)
      'parent' => string 'Mozilla 1.9' (length=11)
      'platform' => string 'Linux' (length=5)
      'browser' => string 'Mozilla' (length=7)
      'version' => string '1.9' (length=3)
      'majorver' => string '1' (length=1)
      'minorver' => string '9' (length=1)
      'alpha' => string '1' (length=1)
      'frames' => string '1' (length=1)
      'iframes' => string '1' (length=1)
      'tables' => string '1' (length=1)
      'cookies' => string '1' (length=1)
      'javaapplets' => string '1' (length=1)
      'javascript' => string '1' (length=1)
      'cssversion' => string '2' (length=1)
      'supportscss' => string '1' (length=1)
      'beta' => string '' (length=0)
      'win16' => string '' (length=0)
      'win32' => string '' (length=0)
      'win64' => string '' (length=0)
      'backgroundsounds' => string '' (length=0)
      'cdf' => string '' (length=0)
      'vbscript' => string '' (length=0)
      'activexcontrols' => string '' (length=0)
      'isbanned' => string '' (length=0)
      'ismobiledevice' => string '' (length=0)
      'issyndicationreader' => string '' (length=0)
      'crawler' => string '' (length=0)
      'aol' => string '' (length=0)
      'aolversion' => string '0' (length=1)
    

    on firefox 3.5 ; and :

    array
      'browser_name_regex' => string '^.*$' (length=4)
      'browser_name_pattern' => string '*' (length=1)
      'browser' => string 'Default Browser' (length=15)
      'version' => string '0' (length=1)
      'majorver' => string '0' (length=1)
      'minorver' => string '0' (length=1)
      'platform' => string 'unknown' (length=7)
      'alpha' => string '' (length=0)
      ....
      'aol' => string '' (length=0)
      'aolversion' => string '0' (length=1)
    

    On a recent version (4.0.203.2) of google chrome for Linux — well, considering it’s some kind of nightly build, I suppose it’s normal that it’s not recognized…

    As a reference, here is it’s user-agent string :

    string 'Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/4.0.203.2 Safari/532.0' (length=109)
    

    This show that get_browser is nice ; but maybe not perfect for some cutting-edge test browser — still, should work fine with most “common” browsers, I suppose…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
Seemingly simple, but I cannot find anything relevant on the web. What is the
I need to clean up various Word 'smart' characters in user input, including but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.