Thread: detect o/s ..
View Single Post
Old 05-09-2002, 04:59 PM   #2 (permalink)
bdl
Senior Contributor
 
Join Date: May 2002
Location: vta.ca.usa
Posts: 555
bdl is on a distinguished road
Well, PHP will do that for you, in a way. You can use the $HTTP_USER_AGENT string to grab what type of browser they're using, and just use a little flow control to deduce which OS. There may very well be another method in PHP, but I don't know it (yet).

Here's a quick example I had worked up awhile back:

Code:
$HTTP_USER_AGENT and strstr() function call:

<?php
if (strstr($HTTP_USER_AGENT, "MSIE")) {
?>
<p align="left">You're using a Microsoft OS.</p>
<?
} else
if (strstr($HTTP_USER_AGENT, "Mozilla")) {
?>
<p align="left">You're using an opensource OS.</p>
<?
} print $HTTP_USER_AGENT;
?>
bdl is offline   Reply With Quote