Browsers

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

aetoc
Forum Commoner
Posts: 37
Joined: Tue Jan 31, 2006 2:48 am

Browsers

Post by aetoc »

I don't know if here is the right place to put this thread so if not sorry :D .

I would like to know if there is a way to know the browser name (IE, Opera e.t.c.)

I don't want to use JS becose what I want to do dosn't work with JS.


Any ideas?
User avatar
Gente
Forum Contributor
Posts: 252
Joined: Wed Jun 13, 2007 9:43 am
Location: Ukraine, Kharkov
Contact:

Post by Gente »

$_SERVER['USER_AGENT'] should be the key
aetoc
Forum Commoner
Posts: 37
Joined: Tue Jan 31, 2006 2:48 am

Post by aetoc »

I'm sorry Gente but the

Code: Select all

$_SERVER['USER_AGENT']
dosn't return anything.
trobale
Forum Newbie
Posts: 24
Joined: Mon Apr 23, 2007 11:42 am

Post by trobale »

It is:

Code: Select all

$_SERVER['HTTP_USER_AGENT']
aetoc
Forum Commoner
Posts: 37
Joined: Tue Jan 31, 2006 2:48 am

Post by aetoc »

Thank you both.
User avatar
Chalks
Forum Contributor
Posts: 447
Joined: Thu Jul 12, 2007 7:55 am
Location: Indiana

Post by Chalks »

is that method infallible? Rather, what I mean is... what if I'm using a really obscure browser, like lynx or something? Every single method I've seen for browser detection had some weird caveat to it that makes it innefective in this or that situation.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

It's a header sent by the client. Nothing prevents the client from sending User-Agent: rama lama ding dong or no User-agent string at all.
Therefore if your well-being depends on detecting the user's browser you have a problem.
User avatar
Chalks
Forum Contributor
Posts: 447
Joined: Thu Jul 12, 2007 7:55 am
Location: Indiana

Post by Chalks »

volka wrote:User-Agent: rama lama ding dong
I would pay money for a browser that did that.

Seriously. :lol:
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

If you don't have access to get_browser()'s browscap file and it's out of date, then http://sourceforge.net/projects/phpsniff/ is a reasonable alternative.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Chalks wrote:
volka wrote:User-Agent: rama lama ding dong
I would pay money for a browser that did that.

Seriously. :lol:
https://addons.mozilla.org/en-US/firefox/addon/59
User avatar
Chalks
Forum Contributor
Posts: 447
Joined: Thu Jul 12, 2007 7:55 am
Location: Indiana

Post by Chalks »

Firefox, oh how I love thee. Let me count the ways!

Edit: if you find me a donate button, I'll donate a dollar. :D

Edit2: Opera, oh how I would love thee, if Firefox hadn't already stolen my heart. Let me count the ways!
Last edited by Chalks on Fri Jul 20, 2007 3:27 pm, edited 1 time in total.
User avatar
AKA Panama Jack
Forum Regular
Posts: 878
Joined: Mon Nov 14, 2005 4:21 pm

Post by AKA Panama Jack »

And in Opera you can edit/change the User Agent.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

onion2k wrote:If you don't have access to get_browser()'s browscap file and it's out of date, then http://sourceforge.net/projects/phpsniff/ is a reasonable alternative.
If get_browser()'s style of use is liked, viewtopic.php?p=237279#237279 ;)
User avatar
Todd_Z
Forum Regular
Posts: 708
Joined: Thu Nov 25, 2004 9:53 pm
Location: U Michigan

Post by Todd_Z »

Firefox does this too without an extension.

about:config
create a var called general.useragent.override and put whatever you want in the value.

i get defensive when people bring up stuff that opera has that firefox doesn't :)
User avatar
AKA Panama Jack
Forum Regular
Posts: 878
Joined: Mon Nov 14, 2005 4:21 pm

Post by AKA Panama Jack »

I just mentioned it to point out that browser sniffing can be a useless thing to do anymore because you never know what browser is really browsing your site.
Post Reply