Posted By

Thresh on 07/01/09


Tagged

php browser detect iphone


Versions (?)

Who likes this?

5 people have marked this snippet as a favorite

jamesming
rickfu
ignace
umang_nine
avanadra


detect iphone browser


 / Published in: PHP
 

URL: http://www.laydo.net/2009/07/01/iphone-tarayici-tespiti-safari/?preview=true&preview_id=281&preview_nonce=368872e6b4

  1. <?
  2.  
  3. function is_iPhone($agent='') {
  4. if(empty($agent)) $agent = $_SERVER['HTTP_USER_AGENT'];
  5. if(!empty($agent) and preg_match("~Mozilla/[^ ]+ \((iPhone|iPod); U; CPU [^;]+ Mac OS X; [^)]+\) AppleWebKit/[^ ]+ \(KHTML, like Gecko\) Version/[^ ]+ Mobile/[^ ]+ Safari/[^ ]+~",$agent,$match)) {
  6. return "YES";
  7. } elseif(stristr($agent,'iphone') or stristr($agent,'ipod')){
  8. return "MAYBE";
  9. } else {
  10. return "NO";
  11. }
  12. }
  13.  
  14. echo is_iPhone();
  15. ?>

Report this snippet  

You need to login to post a comment.