What are the advantages and disadvantages of using a custom function to determine the operating system in PHP compared to the get_browser() function?

When determining the operating system in PHP, using a custom function allows for more control and flexibility in how the detection is done. However, it may require more time and effort to develop and maintain compared to using the built-in get_browser() function, which provides a simpler way to retrieve browser information but may not always be accurate.

function getOperatingSystem() {
    $userAgent = $_SERVER['HTTP_USER_AGENT'];
    
    if (strpos($userAgent, 'Windows') !== false) {
        return 'Windows';
    } elseif (strpos($userAgent, 'Macintosh') !== false) {
        return 'Macintosh';
    } elseif (strpos($userAgent, 'Linux') !== false) {
        return 'Linux';
    } else {
        return 'Unknown';
    }
}

$operatingSystem = getOperatingSystem();
echo "Operating System: " . $operatingSystem;