Posted By

benhomie on 08/06/10


Tagged


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

roli000
thezoomer
d55beck


Detect Mobile Devices (useragent)


 / Published in: PHP
 

  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  

You need to login to post a comment.