Detecting Mobile Browsers

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
SpecialK
Forum Commoner
Posts: 96
Joined: Mon Sep 18, 2006 3:49 pm

Detecting Mobile Browsers

Post by SpecialK »

I have a request to automatically detect the browser and output a mobile version of the website.

This worked fine when it was just supposed to support BlackBerry as they have an extra variable set called $_SERVER["HTTP_PROFILE"]

Now I am supposed to add support for Windows CE and Palm, CE was easy enough to find a working emulator and add it's own variable. Palm I am having issues. This can get huge fast if I'm checking for a certain variable in each type of mobile browser and not a good design choice.

My question, is there an efficient way to detect mobile browsers?
I know I could use the HTTP_USER_AGENT string and try to parse for different type of OS's. The problem there lies knowing which ones to detect for any knowing the difference between the many types out there.

The goal is not to have to create a new ip name, ex. mobile.xxx.xxx and use the current name.
Citizen
Forum Contributor
Posts: 300
Joined: Wed Jul 20, 2005 10:23 am

Post by Citizen »

Check this out:

http://www.phpclasses.org/browse/package/2000.html

Also, do you work for kellogs? :)
User avatar
SpecialK
Forum Commoner
Posts: 96
Joined: Mon Sep 18, 2006 3:49 pm

Post by SpecialK »

Thanks for the direction. That class will save me tons of work and give lots of extensibility.

BTW: I don't work for Kellogg's ;)
Post Reply