Expected result should be 1. You are browsing from Chrome 75.0.3770.142 (Windows 10) 2. Your device has monitor res. 1366x768px , 4-cores CPU .
Asked
Active
Viewed 690 times
-1
-
The browser info is readily available from the [`$_SERVER`](https://www.php.net/manual/en/reserved.variables.server.php) variable, but the rest cannot be retrieved with PHP. Javascript might be able to get the resolution, but the computer info would be tricky. – aynber Jul 25 '19 at 13:29
-
as this are client information, get them from the client, have a google for "js browser fingerprint" leading you e.g. fingerprint.js – FatFreddy Jul 25 '19 at 13:38
-
js is the best solution for my query but is there any to find out through php. – RASHED Jul 25 '19 at 13:51
2 Answers
0
This might help! Using get_browser() will at least get you part of what you're looking for!
<?php
echo $_SERVER['HTTP_USER_AGENT'] . "\n\n";
$browser = get_browser(null, true);
echo "<pre>";
print_r($browser);
echo "</pre>";
0
<?php
function getBrowser() {
$u_agent = $_SERVER['HTTP_USER_AGENT'];
$bname = 'Unknown';
$platform = 'Unknown';
$version= "";
if (preg_match('/linux/i', $u_agent)) {
$platform = 'linux';
} elseif (preg_match('/macintosh|mac os x/i', $u_agent)) {
$platform = 'mac';
} elseif (preg_match('/windows|win32/i', $u_agent)) {
$platform = 'windows';
}
if(preg_match('/MSIE/i',$u_agent) && !preg_match('/Opera/i',$u_agent)) {
$bname = 'Internet Explorer';
$ub = "MSIE";
} elseif(preg_match('/Firefox/i',$u_agent)) {
$bname = 'Mozilla Firefox';
$ub = "Firefox";
} elseif(preg_match('/Chrome/i',$u_agent)) {
$bname = 'Google Chrome';
$ub = "Chrome";
} elseif(preg_match('/Safari/i',$u_agent)) {
$bname = 'Apple Safari';
$ub = "Safari";
} elseif(preg_match('/Opera/i',$u_agent)) {
$bname = 'Opera';
$ub = "Opera";
} elseif(preg_match('/Netscape/i',$u_agent)) {
$bname = 'Netscape';
$ub = "Netscape";
}
$known = array('Version', $ub, 'other');
$pattern = '#(?<browser>' . join('|', $known) . ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
if (!preg_match_all($pattern, $u_agent, $matches)) {
}
$i = count($matches['browser']);
if ($i != 1) {
if (strripos($u_agent,"Version") < strripos($u_agent,$ub)){
$version= $matches['version'][0];
} else {
$version= $matches['version'][1];
}
} else {
$version= $matches['version'][0];
}
if ($version==null || $version=="") {$version="?";}
return array(
'userAgent' => $u_agent,
'name' => $bname,
'version' => $version,
'platform' => $platform,
'pattern' => $pattern
);
}
$browser = getBrowser();
print_r($browser);

Nidhi Gupta
- 41
- 4
-
I am working on it. So fat I have checked and found that It can only be possible with Javascript. But I am still working on it. – Nidhi Gupta Jul 25 '19 at 13:50
-
Please check: https://stackoverflow.com/questions/1504459/getting-the-screen-resolution-using-php – Nidhi Gupta Jul 25 '19 at 13:53
-