# iPod and iPhone detection



## namenotfound (Apr 30, 2005)

If I want to check for two different user agents, will this work?


```
<?php
if (strpos($_SERVER['HTTP_USER_AGENT'], 'iPod' || 'iPhone') !== FALSE) {
  echo "Some Stuff Here";
}
?>
```
Or will I have to do it separate like this?


```
<?php
if (strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') !== FALSE) {
  echo "Some Stuff Here";
}
elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'iPod') !== FALSE) {
  echo "Some Stuff Here";
}
?>
```
These are the two user agent strings I'm working with


```
Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/3A110a Safari/419.3
Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543 Safari/419.3
```


----------



## Fyzbo (Feb 6, 2002)

I don't know the exact answer for your question, but here are some good articles on the topic.

http://www.alistapart.com/articles/putyourcontentinmypocket/
http://www.alistapart.com/articles/putyourcontentinmypocketpart2


----------



## brendandonhu (Jul 8, 2002)

```
<?php
if(strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') || strpos($_SERVER['HTTP_USER_AGENT'], 'iPod'))
{
  echo "Some Stuff Here";
}
?>
```
Or you can use preg_match() or even get_browser().


----------

