skip to Main Content

Simple php code to detect browser

Ever needed a php code to determine browser and version? i know most of us would like to know, especially if it’s the browser we love to hate. With this little snippet.. we could even determine the version.. So let me leave this code to your imagination.. easy to use..

$IE6 = (ereg('MSIE 6',$_SERVER['HTTP_USER_AGENT'])) ? true : false;     
$IE7 = (ereg('MSIE 7',$_SERVER['HTTP_USER_AGENT'])) ? true : false;     
$IE8 = (ereg('MSIE 8',$_SERVER['HTTP_USER_AGENT'])) ? true : false; 
if (($IE6 == 1) || ($IE7 == 1) || ($IE8 == 1)) 
{  
     // Do fallback stuff that old browsers can do here    
     echo "Shit its ie!"; 
} else { 
     // do stuff that real browsers can handle here
}  

Source : http://www.davidwells.tv/how-to-detect-specific-versions-of-internet-explorer-in-php-and-show-different-fallback-content/

Alphonse

Editorial Staff at ETN Multimedia is led by Alphonse Tan. Page maintained by Alphonse Tan

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top