Posted By

dropthenerd on 01/20/11


Tagged

mobile user agent iphone ipod touch iPad


Versions (?)

How to easily detect mobile devices


 / Published in: PHP
 

URL: http://www.dropthenerd.com/how-to-easily-detect-mobile-devices/

  1. function mobileCheck(){
  2. $mobile = isset($_GET['mobile']) ? true : false;
  3. $user_agent = $_SERVER['HTTP_USER_AGENT'];
  4.  
  5. $devices = array('iPhone','iPod','iPad');
  6.  
  7. foreach($devices as $device){
  8. if(strpos($user_agent,$device) || $mobile == true) return true;
  9. }
  10. return false;
  11. }

Report this snippet  

You need to login to post a comment.