I am working in PHP on putting in better logging into my error handling system. As part of this i want to get out the users browser name and version and their OS.
So we after something like Firefox 3 and Windows Vista in my case.
Now I know we can get the user agent which technically does contain this information, although it requires some processing first. Details are often stored in different places depending on OS and browser.
Obviously I would be using get_browser() but this is not supported in the installation of PHP I have and I don't have the relative permissions to change this.
Any ideas on how best to do this?
Note, I want to do this in PHP, not Javascript.
Cheers guys.
if(strpos($_SERVER['HTTP_USER_AGENT'],'MSIE') !== false) echo 'Internet explorer';
remember, you must compare strpos to false. NOT to true. you can use ===false or !==false
try that :)
I don't see how it's possible to determine browser/OS except through the user agent string.
Oh, i know this has to be done through the user agent, it is more than i need something human readable. I dont want it to spit back that i have Windows NT 6.0 or something, I want it to work out Vista. I guess im more looking for smart conversion tables than anything else. The feature is in PHP and there are even ways to get updates for such tables, but it is turned off in my install.
Browser: Mozilla/Netscape 6.x OS: Microsoft Windows NT
I am looking for something that actually figures out I have Vista and Firefox 3.
echo 'OS: '.Net_UserAgent_Detect::getOSString().'<br />Browser: '.Net_UserAgent_Detect::getBrowserString();
PEAR has a popular package that does this: http://pear.php.net/package/Net_UserAgent_Detect/ Ugly code, but meh.
Ugly code, but meh.
That looks like exactly what I'm looking for. I don't suppose you have any experience in implementing this? As per usual Pear's documentation is very poor and I am having a hard time chasing docs after docs and not got it working as yet.