I want to know when a Windows Phone is on page so having it’s user agent that is
Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0;)
I use this code, without luck. What am I missing here?
if (strpos($_SERVER['HTTP_USER_AGENT'], Windows Phone) == false) {
echo"mango";
}
I also tried Phone, IEMobile but nothing.
Looks like you’re missing some quotes around your search string. Also, you appear to be checking for the wrong condition.
strpos()returnsfalseif it can’t find the string. You want to check for non-false results