/ Published in: PHP
URL: http://afj176.com
Place in your functions.php file and call it in your theme like this: <?php>
Expand |
Embed | Plain Text
/*Browser Detect*/ function browser_detect(){ $ipod = stripos($_SERVER['HTTP_USER_AGENT'],"iPod"); $iphone = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone"); $firefox = stripos($_SERVER['HTTP_USER_AGENT'],"Firefox"); $safari = stripos($_SERVER['HTTP_USER_AGENT'],"Safari"); $ie = stripos($_SERVER['HTTP_USER_AGENT'],"MSIE"); $opera = stripos($_SERVER['HTTP_USER_AGENT'],"Opera"); $maxthon = stripos($_SERVER['HTTP_USER_AGENT'],"Maxthon"); $chrome = stripos($_SERVER['HTTP_USER_AGENT'],"Chrome"); $netscape = stripos($_SERVER['HTTP_USER_AGENT'],"Netscape"); $traveler = stripos($_SERVER['HTTP_USER_AGENT'], "Traveler"); //detecting device if ($ipod == true || $iphone == true){ echo "<div class=\"browser\">"; echo "<img src=\"images/iphone.png\">"; echo "<br />"; echo "<p>You are viewing this site on an Ipod or Iphone</p>"; echo "</div>"; }elseif($firefox == true){ echo "<div class=\"browser\">"; echo "<img src=\"images/Firefox.png\">"; echo "<br />"; echo "<p>You are viewing this site in Firefox</p>"; echo "</div>"; }elseif($ie == true){ echo "<div class=\"browser\">"; echo "<img src=\"images/IE.png\">"; echo "<br />"; echo "<p>You are viewing this site in Internet Explorer</p>"; echo "</div>"; }elseif($netscape == true){ echo "<div class=\"browser\">"; echo "<img src=\"images/Netcape.png\">"; echo "<br />"; echo "<p>You are viewing this site in Netscape</p>"; echo "</div>"; }elseif($traveler == true){ echo "<div class=\"browser\">"; echo "<img src=\"images/Traveler.png\">"; echo "<br />"; echo "<p>You are viewing this site in Traveler</p>"; echo "</div>"; }elseif($maxthon == true){ echo "<div class=\"browser\">"; echo "<img src=\"images/Maxthon.png\">"; echo "<br />"; echo "<p>You are viewing this site in Maxthon</p>"; echo "</div>"; }elseif($chrome == true){ echo "<div class=\"browser\">"; echo "<img src=\"images/Chrome.png\">"; echo "<br />"; echo "<p>You are viewing this site in Chrome</p>"; echo "</div>"; }elseif($safari == true){ echo "<div class=\"browser\">"; echo "<img src=\"images/Safari.png\">"; echo "<br />"; echo "<p>You are viewing this site in Safari</p>"; echo "</div>"; }elseif($opera == true){ echo "<div class=\"browser\">"; echo "<img src=\"images/Opera.png\">"; echo "<br />"; echo "<p>You are viewing this site in Opera</p>"; echo "</div>"; }else{ echo "<div class=\"browser\">"; echo "<img src=\"images/Q.png\">"; echo "<br />"; echo "<p>We currently dont know your browser.</p>"; echo "</div>"; } };
Comments
Subscribe to comments
You need to login to post a comment.

i just added android: $android = stripos($SERVER['HTTPUSER_AGENT'], "Android");
and
elseif($android == true){ echo ""; echo ""; echo ""; echo "
You are viewing this site on Android
"; echo "";