Wednesday 9 April 2014

PHP Code To Find Web Browser And Operating System

This will help you to find, what kind of browser and operating system is used to view this page? 
 Here you can find the code please click below
DEMO
index.php

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>PHP Code to find web browser and operating system</title>
</head>
<body>
<?php
$view = getenv( "HTTP_USER_AGENT" );
$browser = "An unidentified browser";
if( preg_match( "/MSIE/i", "$view" ) )
{
$browser = "Internet Explorer";
}
else if( preg_match( "/Chrome/i", "$view" ) )
{
$browser = "Chrome";
}
else if( preg_match( "/Mozilla/i", "$view" ) )
{
$browser = "Mozilla";
}
$platform = "An unidentified OS!";
if( preg_match( "/Windows/i", "$view" ) )
{
$platform = "Windows!";
}
else if ( preg_match( "/Linux/i", "$view" ) )
{
$platform = "Linux!";
}
echo("You are using $browser as browser on operating system $platform");
?>

</body>
</html>


No comments:

Post a Comment

Printing first 50 Fibonacci numbers Using PHP Program

Fibonacci series is a series of numbers in which each number is the sum of the two preceding numbers. For example. 0 , 1 , 1 , 2 , 3 , 5...