How to print the version of macOS? Even the name of the operating system?

print out

after using $_ SERVER ["HTTP_USER_AGENT"]
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36

find

on posts

function os_info($uagent)
{
    // the order of this array is important
    global $uagent;
    $oses   = array(
        "Win311" => "Win16",
        "Win95" => "(Windows 95)|(Win95)|(Windows_95)",
        "WinME" => "(Windows 98)|(Win 9x 4.90)|(Windows ME)",
        "Win98" => "(Windows 98)|(Win98)",
        "Win2000" => "(Windows NT 5.0)|(Windows 2000)",
        "WinXP" => "(Windows NT 5.1)|(Windows XP)",
        "WinServer2003" => "(Windows NT 5.2)",
        "WinVista" => "(Windows NT 6.0)",
        "Windows 7" => "(Windows NT 6.1)",
        "Windows 8" => "(Windows NT 6.2)",
        "Windows 8.1" => "(Windows NT 6.3)",
        "Windows 10" => "(Windows NT 10.0)",
        "WinNT" => "(Windows NT 4.0)|(WinNT4.0)|(WinNT)|(Windows NT)",
        "OpenBSD" => "OpenBSD",
        "SunOS" => "SunOS",
        "Ubuntu" => "Ubuntu",
        "Android" => "Android",
        "Linux" => "(Linux)|(X11)",
        "iPhone" => "iPhone",
        "iPad" => "iPad",
        "MacOS" => "(Mac_PowerPC)|(Macintosh)",
        "QNX" => "QNX",
        "BeOS" => "BeOS",
        "OS2" => "OS/2",
        "SearchBot" => "(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp)|(MSNBot)|(Ask Jeeves/Teoma)|(ia_archiver)"
    );
    $uagent = strtolower($uagent ? $uagent : $_SERVER["HTTP_USER_AGENT"]);
    foreach ($oses as $os => $pattern)
        if (preg_match("/" . $pattern . "/i", $uagent))
            return $os;
    return "Unknown";
}
echo os_info($uagent);

this can print "MacOS"
, but suppose I want to print the later version "10-10-5". What code can I use to do that? Because the length may not be necessarily

Mar.05,2021

regular

/Mac OS X ([\d\_]+)/

try get_browser as:

<?php
$osInfo = get_browser(null, true);
var_export($osInfo);

however, this API depends on the browscap configuration in php.ini, and the browscap.ini file it points to can provide the mapping between the specific uA and the operating system; the latest version can go to here .


https://github.com/WhichBrows.

https://github.com/ua-parser/.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b386f5-2c11e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b386f5-2c11e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?