how to get exact browser name and version

Get browser name and version using javascript

With the help of JavaScript we can determine exact browser name and its version. The JavaScript object “navigator.userAgent” contains the complete information of a browser like CodeName, Name, Version etc. With the help of regular expressions we can extract the information that we need.

<!DOCTYPE html>
<html>
<head>
<script>
function detectBrowser(){
var N= navigator.appName;
var UA= navigator.userAgent;
var temp;
var browserVersion= UA.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);
if(browserVersion && (temp= UA.match(/version\/([\.\d]+)/i))!= null)
browserVersion[2]= temp[1];
browserVersion= browserVersion? [browserVersion[1], browserVersion[2]]: [N, navigator.appVersion,'-?'];
return browserVersion;
};
function browserCheck(){
alert(detectBrowser());
}
</script>
</head>
<body>
</br>
</br></br>
<button onclick="browserCheck();">Click here to check!</button>
</body>
</html>

Get browser name and version using PHP

Here we are determine exact browser name and its version with the help of PHP.

$browserAgent = $_SERVER['HTTP_USER_AGENT'];
echo $browserAgent;

OR
You can also try this code

function GetBrowserName()
{

$GetBrowserNameUA=$_SERVER[‘HTTP_USER_AGENT’];

If (strpos(strtolower($GetBrowserNameUA), “safari/”) and strpos(strtolower($GetBrowserNameUA), “opr/”)) {
// OPERA
$GetBrowserNameBR=”Opera”;
} ElseIf (strpos(strtolower($GetBrowserNameUA), “safari/”) and strpos(strtolower($GetBrowserNameUA), “chrome/”)) {
// CHROME
$GetBrowserNameBR=”Chrome”;
} ElseIf (strpos(strtolower($GetBrowserNameUA), “msie”)) {
// INTERNET EXPLORER
$GetBrowserNameBR=”Internet Explorer”;
} ElseIf (strpos(strtolower($GetBrowserNameUA), “firefox/”)) {
// FIREFOX
$GetBrowserNameBR=”Firefox”;
} ElseIf (strpos(strtolower($GetBrowserNameUA), “safari/”) and strpos(strtolower($GetBrowserNameUA), “opr/”)==false and strpos(strtolower($GetBrowserNameUA), “chrome/”)==false) {
// SAFARI
$GetBrowserNameBR=”Safari”;
} Else {
// OUT OF DATA
$GetBrowserNameBR=”OUT OF DATA”;
};

return $GetBrowserNameBR;
}

echo GetBrowserName();

Leave a Reply

Related Posts: You may like

How to remove whitespace from string using php

Remove All Special Characters From String PHP

Get Latitude Longitude from Address

Redirecting HTTP to HTTPS with PHP

Tools:

Crypto Currency

PHPKIDA provides free online the best real-time crypto market price, news, predictions, index with graphs & historical data for 2000+ coins including bitcoin, ethereum, & altcoins from major cryptocurrency exchanges.

Visite Tool

Icon Generator

PHPKIDA provides free online icon generator. Our icon generator help you to edit, modify, resize and customize icon for your website and applications. Convert to a shap you like add icon border, you can change icon border color, border size, background color, icon shadow, icons color, icon size in your own way and save it as a png image.

Visite Tool

Youtube Video Downloader

PHPKIDA provides Free online YouTube video downloader to download YouTube videos quickly in MP4, 3GP, and more. Search your video and free fast download youtube videos.

Visite Tool

Sign up for weekly update

Milkshake is almost ready. If you're interested in testing it out, then sign up below to get exclusive access.