A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2008 yearHow do I determine whether it's a mobile device with PHP? - page 1
User InfoPosts
How do I determine whether it's a mobile device with PHP?#1
I am writing a website with PHP. Since it will need to be accessed by anyone on the network to access the internet I have to create a mobile version. How do I best check if it's a mobile device? I don't want to have a switch statement with 50 devices at the end since I don't only want to support the iPhone.

Is there a PHP class I could use?

posted date: 2008-12-22 03:36:00


Re: How do I determine whether it's a mobile device with PHP?#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2008-12-22 03:36:01


Re: How do I determine whether it's a mobile device with PHP?#3
You need to check several headers that the client sends, such as USER_AGENT and HTTP_ACCEPT. Check out this article for a comprehensive detection script for mobile user-agents in PHP.

posted date: 2008-12-22 03:42:00


Re: How do I determine whether it's a mobile device with PHP?#4
Would the user agent in the request give you enough info to make a decision?There is a good list of user agents here.

posted date: 2008-12-22 03:43:00


Re: How do I determine whether it's a mobile device with PHP?#5
If they're using their own detection, then it's broken. It told me my Opera 10 on Mac OS X is a mobile browser.

posted date: 2008-12-22 04:16:00


Re: How do I determine whether it's a mobile device with PHP?#6
For detection based on User-Agent, use WURFL database. At least it's comprehensive and continually updated.If you target only high-end(ish) phones, then you may not need to detect them at all, just embed appropriate mobile stylesheets.

posted date: 2008-12-22 04:18:00


Re: How do I determine whether it's a mobile device with PHP?#7
I didn't debug their script if that's what you're asking :) Of course, you should always test everything you read on the Internet, but the principle is there

posted date: 2008-12-22 04:41:00


Re: How do I determine whether it's a mobile device with PHP?#8
Another thing to consider: A lot of sites will actually offer a different URL for mobile devices. See http://m.facebook.com as an example. With the increasing ability of devices these days, this gives your users an option. If they're on a device which can actually handle a full website nicely (using zooming and whatnot), then they'd probably get pretty annoyed being forced into a particular layout.

posted date: 2008-12-22 04:56:00


Re: How do I determine whether it's a mobile device with PHP?#9
As said its a portal for the people to login I can't expect them to know the address to the login server..

posted date: 2008-12-22 06:49:00


Re: How do I determine whether it's a mobile device with PHP?#10
If you want adapt the content to any particular device e.g. to resize images to be the width of the device, then you can also use DeviceAtlas. Based on the useragent of the requesting device, it will tell you the size of the screen, along with supported image formats, supported markup types, maximum page size and so on.

posted date: 2008-12-22 06:51:00


Re: How do I determine whether it's a mobile device with PHP?#11
Most mobile websites use the user_agent exclusively. An opensource database of device capabilities is maintained at http://wurfl.sourceforge.net/ Using wurlf, and based on the user_agent, you can identify the screen physical and pixel width, length, and many more parameters, and make your rendering decision.

posted date: 2009-01-12 14:49:00


Re: How do I determine whether it's a mobile device with PHP?#12
What is a mobile device? Weaker CPU? Lower bandwidth? In reality, it has a screen the resolution of which is below 320x240 and color depth is below 24.You have to use Javascript also. This link will give you an idea:http://www.w3schools.com/js/tryit.asp?filename=tryjs_browsermonitorAnd, this link will teach you what is what:http://www.w3schools.com/htmldom/dom_obj_screen.asp

posted date: 2009-01-12 15:00:00


select page: « 1 2 »
Copyright ©2008-2017 www.momige.com, all rights reserved.