detect iphone browser


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



Copy this code and paste it in your HTML
  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. ?>

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.