Detect Mobile Devices (useragent)


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. $iphone = strpos($_SERVER['HTTP_USER_AGENT'],”iPhone”);
  3. $ipod = strpos($_SERVER['HTTP_USER_AGENT'],”iPod”);
  4. $ipad = strpos($_SERVER['HTTP_USER_AGENT'],”iPad”);
  5. $android = strpos($_SERVER['HTTP_USER_AGENT'],”Android”);
  6. $palmpre = strpos($_SERVER['HTTP_USER_AGENT'],”webOS”);
  7. if($iphone || $ipod || $ipad || $android || $palmpre)
  8. {
  9. //do something here
  10. }
  11. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.