|
|
| Welcome to the Mac Forums forums. Please read the FAQ if you have questions. Register to participate. |
|
|||||||
| TouchArcade.com - iPhone Game Reviews and News |
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
|
#1 |
|
macrumors member
Join Date: Sep 2001
|
Here is how to detect a mobile device using php.
For anyone who wants to use it..
This is a way to detect with php if a visitor to your web site is using a mobile device browser.. it works. If you have a mobile device that this doesn't detect, all you have to do to add it is to find a unique bit of identifying information in your device's user agent and stick it in the list of mobile devices in this code. ------------ <?php /* detect mobile device*/ $ismobile = 0; $container = $_SERVER['HTTP_USER_AGENT']; // A list of mobile devices $useragents = array ( 'Blazer' , 'Palm' , 'Handspring' , 'Nokia' , 'Kyocera', 'Samsung' , 'Motorola' , 'Smartphone', 'Windows CE' , 'Blackberry' , 'WAP' , 'SonyEricsson', 'PlayStation Portable', 'LG', 'MMP', 'OPWV', 'Symbian', 'EPOC', ); foreach ( $useragents as $useragents ) { if(strstr($container,$useragents)) { $ismobile = 1; } } if ( $ismobile == 1 ) { echo "<p>mobile device</p>"; echo $_SERVER['HTTP_USER_AGENT']; } ?>
__________________
mailto:web@shackelfordcreative.com Last edited by nerveosu : May 31, 2006 at 02:51 PM. |
|
|
|
|
|
#2 |
|
macrumors newbie
Join Date: Oct 2008
|
You can see here a few other (better) methods to detect a mobile device: http://beradrian.wordpress.com/2008/...e-recognition/
|
|
|
|
|
|
#3 | |
|
macrumors 601
Join Date: Aug 2005
Location: Dayton, OH
|
Quote:
|
|
|
|
|
|
|
#4 |
|
macrumors newbie
Join Date: Nov 2008
|
there is also a web service out there that provides GEO location as well as handset information real time.
There are a few out there that do this, but we use handsetdetection.com when developing new sites for clients. |
|
|
|
| qwertydesign |
| View Public Profile |
| Find More Posts by qwertydesign |
|
|
#5 |
|
macrumors member
Join Date: May 2004
|
wouldn't
Code:
in_array($_SERVER['HTTP_USER_AGENT'], $useragents)
__________________
Macbook C2D iPod Nano 4Gb |
|
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|