PHP Browser Detection Script
Simple php script identifies the browser name you are using in the
mobile and desktop.
Features
- The script finds out the different type of web browsers used by your
customers.
- Versions of browser can also be identified by using this php script.
- Fully responsive and easy to integrate.
- It detects all the modern web and mobile browsers.
Preview
Browser Detection Script
Your browser: Internet Explorer 7.0
Downloads
<?php
function get_browser_name()
{
$useragent = $_SERVER['HTTP_USER_AGENT'];
$browser = 'Unknown';
$version= "";
if(preg_match('/MSIE/i',$useragent) && !preg_match('/Opera/i',$useragent))
{
$browser = 'Internet Explorer';
$ub = "MSIE";
}
elseif(preg_match('/Firefox/i',$useragent))
{
$browser = 'Mozilla Firefox';
$ub = "Firefox";
}
elseif(preg_match('/Chrome/i',$useragent))
{
$browser = 'Google Chrome';
$ub = "Chrome";
}
elseif(preg_match('/Safari/i',$useragent))
{
$browser = 'Apple Safari';
$ub = "Safari";
}
elseif(preg_match('/Opera/i',$useragent))
{
$browser = 'Opera';
$ub = "Opera";
}
elseif(preg_match('/Netscape/i',$useragent))
{
$browser = 'Netscape';
$ub = "Netscape";
}
$known = array('Version', $ub, 'other');
$pattern = '#(?<browser>' . join('|', $known) .
')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
if (!preg_match_all($pattern, $useragent, $matches)) {
// we have no matching number just continue
}
$i = count($matches['browser']);
if ($i != 1) {
if (strripos($useragent,"Version") < strripos($useragent,$ub)){
$version= $matches['version'][0];
}
else {
$version= $matches['version'][1];
}
}
else {
$version= $matches['version'][0];
}
if ($version==null || $version=="") {$version="?";}
return array(
'userAgent' => $useragent,
'name' => $browser,
'version' => $version
);
}
$ua=get_browser_name();
$yourbrowser= "Your browser: " . $ua['name'] . " " . $ua['version'];
echo "<p align=center><font style='color:green;'><b>$yourbrowser</b></font></p>";
?>
- Release Date - 10-07-2015
- Get free version without ©copyright link for just $10/-
- For customization of this script or any script development, mail to support@hscripts.com
Usage
- Copy and paste the given code in your page and make use of the script.
- Here the function get_browser_name() is used to obtain the various browsers name.
- Simple php script detects the widely used web browsers in your website.
License
Related Scripts