You can get a lot of information about a visitor just by using the phpinfo page. Create a new file, and use this one line, save and upload to your site as phpinfo.php.
phpinfo.php
Then, view that page from your browser and you'll see a ton of the $_SERVER based variables which can give you a lot of info (like ip, referrer, and so on).
Browser and OS information I think is best done via javascript since PHP is a server side language, and java can detect that information. Might check the Javascript section of this forum for more info. Those guys are pretty snazzy with that info.