Browser content : HTTP_USER_AGENT « HTML « PHP






Browser content

 
<html>
 <head>
  <title>Browser content</title>
 </head>
 <body>

 <?php
  $viewer = getenv( "HTTP_USER_AGENT" );

  $browser = "an unidentified browser";
  if( preg_match( "/MSIE/i", "$viewer")){ $browser = "Internet Explorer"; }
  else if( preg_match( "/Netscape/i", "$viewer"))
  { $browser = "Netscape"; }
  else if( preg_match( "/Opera/i", "$viewer"))
  { $browser = "Opera"; }

  $platform = "an unidentified operating system";
  if( preg_match( "/Windows/i", "$viewer"))
  { $platform = "Windows"; }
  else if( preg_match( "/Linux/i", "$viewer"))
  { $platform = "Linux"; }

  echo( "You're using $browser on $platform" );
 ?>

 </body>
</html>
  
  








Related examples in the same category

1.Browser Detection
2.Determining client operating system and browser
3.Get Browser and Platform
4.Welcome Page with HTTP_USER_AGENT
5.Reporting the User Agent and Referrer