Results 1 to 3 of 3

Thread: Using php Function

  1. #1
    Join Date
    Jun 2010
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Using php Function

    Hello guys,

    I wanna ask, how to know If the visitor to my website using a mobile phone or PC? using php function

    Any answers as fast as possible
    Thnx

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    It's not possible to know for sure. You can check the user agent as sent by the browser (might be missing or fake) with $_SERVER['USER_AGENT']
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    what's your purpose (why do you need to know)? if you're redirecting mobile users to a mobile version of your website, can check for known mobile browser UA strings and redirect them when found. It won't catch all of them (there are constantly new ones), and some might be PC browsers that have a similar UA string (shouldn't happen often, maybe not at all).

    And of course (as Daniel says), the UA can always be missing, wrong, or faked.

    The best option (if this is your purpose) is to put a link in the top left corner of your site that allows users to switch between your mobile and full-size sites at will. Mobile users will remember to bookmark the mobile version next time.

    If this isn't what you're doing, let us know.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •