Iphone Detect with PHP

Widget & Mobile Development — admin @ April 1st, 2008

If you need to detect the iphone with PHP use the following code.

function detectiPhone($query){
$container = $_SERVER[’HTTP_USER_AGENT’];

$useragents = array (
“iPhone”,”iPod”);
$this->iphone = false;
foreach ( $useragents as $useragent ) {
if (eregi($useragent,$container)){
$this->iphone = true;
}
}
if($this->iphone){
echo (”This is a iphone or iphone touch - do something like redirect here”);
}else{
echo (”You are not on an iPhone or iPod touch”);
}
}

?>

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google

1 Comment »

  1. great THANKS!

    Comment by luke — May 12, 2008 @ 9:04 am

RSS feed for comments on this post. TrackBack URI

Leave a comment

(c) 2008 Pump Interactive | powered by WordPress