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
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
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/
and here is a PHP script that may help you:
/* 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=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/
and here is a PHP script that may help you:
/* 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
No problem.
:: Copyright KIRUPA 2024 //--