1

Microsoft says we can use the following javascript to detect Windows 11 (on the client side):

navigator.userAgentData.getHighEntropyValues(
   ["architecture", "model", "platform", "platformVersion", "uaFullVersion"])
      .then(ua => { console.log(ua) });

The response should be like: platformVersion: "14.0.0".

I need to use this as a variable in my PHP to detect if a user is using Windows 11:

if(is_browser_request()){   

$user_agent = $_SERVER['HTTP_USER_AGENT'];
$systemid = $_SERVER['HTTP_SEC_CH_UA_PLATFORM'];
$version = Unknown how to define

if (stripos($user_agent, "iPhone")!==false) {
    $brand = 'iPhone';
} else if ($version == "14.0.0") {
    $brand = 'Win11';
} else if ($version == "10.0.0") {
    $brand = 'Win10';

Does this make sense? How can I get the javascript added in my php and define the $version?

ouflak
  • 2,458
  • 10
  • 44
  • 49
  • 2
    You need to use ajax/xhr request. – Simone Rossaini Jan 21 '22 at 07:50
  • Does this answer your question? [What is the difference between client-side and server-side programming?](https://stackoverflow.com/questions/13840429/what-is-the-difference-between-client-side-and-server-side-programming) – Syscall Jan 21 '22 at 08:01
  • You'll also need a [session](https://www.php.net/manual/en/function.session-start.php) to retain the information for the following requests. Also note that the JS code only works in Edge. What is the end goal here? Maybe it can be achieved in a different way. –  Jan 21 '22 at 08:02
  • @ChrisG Thank you sir! This is to detect and show up everyone's system version on my forum. Yep hopefully I could find a new way. It's been very much inconvenient since Windows 11 will use "Window NT 10.0" which is the same that Windows 10 uses. – Kingto Wong Jan 21 '22 at 08:45
  • I tried to get added between and , but it never worked for my webpages. – Kingto Wong Jan 21 '22 at 08:57
  • HTML is not a programming language, it cannot detect anything. Wouldn't it be easier to just let the user select their OS? –  Jan 21 '22 at 08:59

0 Answers0