Mega Code Archive

 
Categories / Php / Code Snippets
 

This example shows some simple browser detection

<?php $msie = eregi("MSIE" , $HTTP_USER_AGENT); //look for MSIE in the HTTP_USER_AGENT if ($msie == true) { echo ("You are using Internet explorer"); //header("location: internetexplorerpage.htm"); exit; } //now we will look for mozilla and of course if its not internet explorer //we will assume its netscape navigator $ns = eregi("mozilla" , $HTTP_USER_AGENT); if ($ns == true) { echo ("You are using Netscape"); //header("location: netscapepage.htm"); exit; } //this is for all other browsers else { echo ("You are not using Netscape or Internet explorer"); //header("location: otherpage.htm"); exit; } ?>