Thursday, August 1, 2013

How to detect a mobile device using php ?

$useragents = array ( 
'Blazer' ,
'Palm' ,
'Handspring' ,
'Nokia' ,
'Kyocera',
'Samsung' ,
'Motorola' ,
'Smartphone', 
'Windows CE' ,
'Blackberry' ,
'WAP' ,
'SonyEricsson',
'PlayStation Portable', 
'LG', 
'MMP',
'OPWV',
'Symbian',
'EPOC',
); 

if(in_array($_SERVER['HTTP_USER_AGENT'], $useragents)){
  echo "It is mobile device";
}else{
  echo "It is not mobile device";
}

No comments:

Post a Comment