Detecting browser device

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have the following code, so far, in my index page to redirect to a
specialized page if the device is a mobile one.  So far it is the following:

if ( strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') ||
      strpos($_SERVER['HTTP_USER_AGENT'], 'BlackBerry') ||
      strpos($_SERVER['HTTP_USER_AGENT'], 'Palm') ||
      strpos($_SERVER['HTTP_USER_AGENT'], 'Windows CE') ) {
   header("Location: loginmo.php");

I have only tested on an older Palm that uses Windows CE and it works.
I just got a Palm Pre and assumed that this would work because of 'Palm'
in there.  It didn't.  It brought up the full site.

Does anyone know where I can find a complete list for all these
hand-held devices?  I have googled for about a half-hour without success.

Re: Detecting browser device

On 28 Jun 2009, sheldonlg <sheldonlg> wrote:


Quoted text here. Click to load it

What does finding a list of handheld UAs have to do with PHP?  Not
much, as far as I can tell.

ISTM, it might be better to rely on the @media at-rule for CSS, which
allows you to serve a stylesheets for different media types (such as
handheld devices).  You will get a more authoritative answer if you
ask in a more appropriate newsgroup, though.

BTW, I'm not sure how you were searching, because the top result for
my search query provided a solution (written in PHP, no less):


int i;main()"];read('-'-'-',i+++"hell\
o, world!\n",'/'/'/'));}read(j,i,p)
                              ~ Anonymous (1984 IOCCC winner)

Site Timeline