LiveWire Network Peer Answers Peer Support Teen Forums Tech Forums College Forums 643 users online 225494 members 1377 active today Advertise Here Sign In
TeenCollegeTechPhotos | Quizzes | LiveSecret | Memberlist | Dictionary | News | FAQ
Member Spotlight
queenvalentinalina
Movies: a lot of em
Mood: Plain
You have 1 new message.
Emergency Help
Until you sign up you can't do much. Yes, it's free.

Sign Up Now
Membername:
Password:
Already have an account?
Invite Friends
Active Members
Groups
Contests
Moderators
3 online / 60 MPM
Fresh Topics
  LiveWire / Technical Forums / Web Design & Search Engine Optimization / Adding Reply

Quoting Post
Archived Topic: It will not be bumped to the top of the forum.
Topic PHP issue
Membername   Not a member? Sign Up Free (takes 20 seconds)
Password   Forgotten your password?
Post

Font:   Size:   Color:

FAQ Keyword Search:
Post Options
Favorites Manager
Notify me of new replies to this topic by email
Notify me of new replies to this topic by private message
Original Post
pleaseremove Posted at 1:29 pm on Dec. 30, 2008
OK, usual reminder, only reply if you have something useful to add, people saying "Wat?" etc will have their posts removed.

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.

Replies
Macropiper Posted at 11:19 pm on Jan. 21, 2009
I would use regular expressions to extract the information out of the user agent, best place to start is by obtaining a nice long diverse list of user agents and keep working at the code till it processes them all perfectly.
jkjslkjind Posted at 11:39 pm on Dec. 30, 2008
and if you wanna find browser

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

jkjslkjind Posted at 11:37 pm on Dec. 30, 2008
$_SERVER['HTTP_USER_AGENT']

try that :)

pleaseremove Posted at 3:24 pm on Dec. 30, 2008
Quote: from Mediocre at 10:34 pm on Dec. 30, 2008

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.

Mediocre Posted at 2:34 pm on Dec. 30, 2008
I don't see how it's possible to determine browser/OS except through the user agent string.
pleaseremove Posted at 2:18 pm on Dec. 30, 2008
It was looking good, but unfortunately it isn't quite what I am after. It doesn't do much more than reg ex the user agent. At current, when asking for browser and OS i am getting the following:

Browser: Mozilla/Netscape 6.x
OS: Microsoft Windows NT

I am looking for something that actually figures out I have Vista and Firefox 3.

Mediocre Posted at 2:06 pm on Dec. 30, 2008
Basically:

Code:
require_once('Detect.php');

echo 'OS: '.Net_UserAgent_Detect::getOSString().'<br />Browser: '.Net_UserAgent_Detect::getBrowserString();

pleaseremove Posted at 1:56 pm on Dec. 30, 2008
Quote: from Mediocre at 9:34 pm on Dec. 30, 2008

PEAR has a popular package that does this: http://pear.php.net/package/Net_UserAgent_Detect/

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.

Mediocre Posted at 1:34 pm on Dec. 30, 2008
PEAR has a popular package that does this: http://pear.php.net/package/Net_UserAgent_Detect/

Ugly code, but meh.

adriannaa Posted at 1:32 pm on Dec. 30, 2008
Post from this position was omitted due to content violations
All 10 previous replies displayed.