Create a new php page with the line
phpinfo();
Running this will show lots of details about the PHP setup. Near the end 'PHP Variables' shows global variables available all the time, you could use one of these and do string operations and ifs to work out an approxiamate OS eg. NT,XP,9x.
You didn't say whether you wanted the client OS, if you do the above method it will not work. My second method will work for the client, use javascript to get the OS on the client (there are loads of sites on the web giving free scripts for this) and pass it to the PHP page using get or something else. you could probably do something like:
<html>
<head>
<script>
// OS detection
function osDetect() {
?
return os_var;
}
function goToPage() {
document.location = 'page.php?os=' + os_var;
}
</script>
</head>
<body>
<a href="" onClick="goToPage()">Click here</a>
</body>
</html>
Don't expect that code to work out of the box, most of it is pseudocode infact.. All the info is out there.