# Mobile Phone Browser Dectection

**URL:** <https://forum.kirupa.com/t/mobile-phone-browser-dectection/264386>\
**Category:** web dev\
**Created:** [June 25, 2008, 5:28pm UTC](https://forum.kirupa.com/t/mobile-phone-browser-dectection/264386 "2008-06-25T17:28:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Digitalosophy](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/digitalosophy/32/1114_2.png) [@Digitalosophy](https://forum.kirupa.com/u/Digitalosophy)\
**Post date:** [June 25, 2008, 5:28pm UTC](https://forum.kirupa.com/t/mobile-phone-browser-dectection/264386/1 "2008-06-25T17:28:09Z")

</div>

I need a way to detect if a user is browsing from a mobile phone. I haven’t found a way to do this in a clean fashion. It seems I can find the useragent then check it against a list, is that the only way?

Thanks  
D

---

<div class="post-metadata">

**Author:** ![actionAction](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/actionaction/32/3987_2.png) [@actionAction](https://forum.kirupa.com/u/actionAction)\
**Post date:** [June 25, 2008, 5:35pm UTC](https://forum.kirupa.com/t/mobile-phone-browser-dectection/264386/2 "2008-06-25T17:35:08Z")

</div>

On the client side, yes. It should be noted that this is not an extremely reliable means of detection though. Check this out: [http://wurfl.sourceforge.net/](http://wurfl.sourceforge.net/)

and here is a PHP script that may help you:

```php
/* Return TRUE if user is using mobile phone browser */
function ismobile(){
$useragent = $_SERVER['HTTP_USER_AGENT'];
// Standard vendor-model/version user agents
if (preg_match('/^((ACER¦Alcatel¦AUDIOVOX¦BlackBerry¦CDM¦Ericsson¦LG\b¦LGE¦Motorola¦MOT¦NEC¦Nokia¦Panasonic¦QCI¦SAGEM¦SAMSUNG¦SEC¦Sanyo¦Sendo¦SHARP¦SIE¦SonyEricsson¦Telit¦Telit_mobile_Terminals¦TSM)[-]?([^\/\s\_]+))(\/(\S+))?/', $useragent)){
return true;
}else{
return false;
}
}

```

---

<div class="post-metadata">

**Author:** ![Digitalosophy](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/digitalosophy/32/1114_2.png) [@Digitalosophy](https://forum.kirupa.com/u/Digitalosophy)\
**Post date:** [June 25, 2008, 5:49pm UTC](https://forum.kirupa.com/t/mobile-phone-browser-dectection/264386/3 "2008-06-25T17:49:27Z")

</div>

[quote=actionAction;2348968]On the client side, yes. It should be noted that this is not an extremely reliable means of detection though. Check this out: [http://wurfl.sourceforge.net/](http://wurfl.sourceforge.net/)

and here is a PHP script that may help you:

```php
/* Return TRUE if user is using mobile phone browser */
function ismobile(){
$useragent = $_SERVER['HTTP_USER_AGENT'];
// Standard vendor-model/version user agents
if (preg_match('/^((ACER¦Alcatel¦AUDIOVOX¦BlackBerry¦CDM¦Ericsson¦LG\b¦LGE¦Motorola¦MOT¦NEC¦Nokia¦Panasonic¦QCI¦SAGEM¦SAMSUNG¦SEC¦Sanyo¦Sendo¦SHARP¦SIE¦SonyEricsson¦Telit¦Telit_mobile_Terminals¦TSM)[-]?([^\/\s\_]+))(\/(\S+))?/', $useragent)){
return true;
}else{
return false;
}
}

```

[/quote]

Thanks I was actually on that site earlier today. Ok let me see if I can just have PHP installed as it just seems way more economical.

Thanks for your help

---

<div class="post-metadata">

**Author:** ![actionAction](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/actionaction/32/3987_2.png) [@actionAction](https://forum.kirupa.com/u/actionAction)\
**Post date:** [June 25, 2008, 6:29pm UTC](https://forum.kirupa.com/t/mobile-phone-browser-dectection/264386/4 "2008-06-25T18:29:44Z")

</div>

No problem.
