Reputation: 620
I have a flash advert I do not want to display on iPhones and iPads.
What's wrong with this conditional?
<?php
if(strstr($_SERVER['HTTP_USER_AGENT'],'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'],'iPod')) {
// do something
}
else {
// do something else
}
?>
Thank you.
Upvotes: 2
Views: 4694
Reputation: 1926
if(strstr($SERVER['HTTP_USER_AGENT'],'iPhone') || strstr($SERVER['HTTP_USER_AGENT'],'iPod'))
Specifies "iPod" for the second match. Change that to 'iPad'. If you want to do the same for the iPod touch, you'll also need a clause for iPod as you have currently.
The following should work for all 3:
if(strstr($_SERVER['HTTP_USER_AGENT'],'iPod') || strstr($_SERVER['HTTP_USER_AGENT'],'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'],'iPad'))
Upvotes: 6