get_browser() and browscap.ini – PHP

  php

Q(Question):

Hello,
today I stumbled across the function get_browser
(http://be2.php.net/manual/en/function.get-browser.php). Totally
excited, I tried it out. Hmm, didn’t seem to work :-s.

So I read the page again, only a little bit more concetrated. Aha,
"browscap.ini is not bundled with PHP but you may find an up-to-date
browscap.ini file here."

So I visited thát site, but then I stumbled across "Despite my pleas to
have the link from the PHP website removed they refuse to do so. Until
their get_browser() function is fixed I do not recommend using my
browscap.ini file with PHP." And his faq
(http://www.garykeith.com/browsers/faq.asp) tells me:

<faq>
Is your browscap.ini file compatible with PHP?
It used to be, and it may once again be. But for now, due to problems in
get_browser() not my files, I’d have to say no. I am guardedly
optimistic this situation will resolve itself soon.
</faq>
Is there a way to solve this issue? I would like to convince the admin
of the server my site is running on to support get_browser, but if php
doesn’t seem compatible with browscap.ini, then the probably isn’t much
I can do about it… I guess?
greetings,
Mattias

A(Answer):

Is there a way to solve this issue? I would like to convince the admin
of the server my site is running on to support get_browser, but if php
doesn’t seem compatible with browscap.ini, then the probably isn’t much
I can do about it… I guess?

I doubt it.

However, I would implore you to consider why you need to do browser
sniffing. Is it *really* necessary for what you are trying to achieve?
Martin

A(Answer):

Martin Lucas-Smith schreef:
[…]

However, I would implore you to consider why you need to do browser
sniffing. Is it *really* necessary for what you are trying to achieve?

It’s not *really* necessary, but without it, the users of IE6.0 can’t
select anything on http://student.ugent.be/astrid/bewoners.php (strange,
but with IE5.x it worked), just because I had the following on top of my
webpage:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

So I needed code that omitted the DOCTYPE when IE was used and that’s
how I stumbled across get_browser. Of course, I have to other options
that don’t need the browser sniffing:

(1) I just ignore the IE users. But although I really dislike IE (not
because it’s from Microsoft, but because IE doesn’t evolve together with
the webstanders), I can’t ignore those users :-/.

(2) I *always* omit the DOCTYPE. But then my page isn’t W3C compliant.
Conclusion: "If only IE was a browser, better supporting the
webstandards…"
Mattias

A(Answer):

Mattias Campe wrote:

Martin Lucas-Smith schreef:
[…]

However, I would implore you to consider why you need to do browser
sniffing. Is it *really* necessary for what you are trying to
achieve?

It’s not *really* necessary, but without it, the users of IE6.0 can’t
select anything on http://student.ugent.be/astrid/bewoners.php
(strange, but with IE5.x it worked), just because I had the following
on top of my webpage:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

So I needed code that omitted the DOCTYPE when IE was used and that’s
how I stumbled across get_browser. Of course, I have to other options
that don’t need the browser sniffing:

(1) I just ignore the IE users. But although I really dislike IE (not
because it’s from Microsoft, but because IE doesn’t evolve together
with the webstanders), I can’t ignore those users :-/.

(2) I *always* omit the DOCTYPE. But then my page isn’t W3C compliant.

(3) Learn a bit more about the IE6 DOCTYPE switch and adapt your Javascript
or CSS (which probably causes the trouble) accordingly:
http://msdn.microsoft.com/library/en…ments.asp?fram
e=true#cssenhancements_topic2

BTW, I am not sure what you mean by ‘select’ in your statement above — the
page works equally to me on IE6 and Firefox.

If it behave differently on IE5, then the problem is not in PHP, but your
HTML/CSS/Javascript.

Berislav


If the Internet is a Marx Brothers movie, and Web, e-mail, and IRC are
Groucho, Chico, and Harpo, then Usenet is Zeppo.

A(Answer):

Mattias Campe wrote:

However, I would implore you to consider why you need to do browser
sniffing. Is it *really* necessary for what you are trying to achieve?

It’s not *really* necessary, but without it, the users of IE6.0 can’t
select anything on http://student.ugent.be/astrid/bewoners.php (strange,
but with IE5.x it worked), just because I had the following on top of my
webpage:

I’m not sure if browser sniffing is your best solution but if you really
must do it, if the $_SERVER[‘HTTP_USER_AGENT’] contains ‘MSIE 6.0’ and does
not contain ‘Opera’ then it’s extremely likely to be IE 6.0

Chris


Chris Hope
The Electric Toolbox Ltd
http://www.electrictoolbox.com/

A(Answer):

Berislav Lopac schreef:

Mattias Campe wrote:

Martin Lucas-Smith schreef:
[…]

However, I would implore you to consider why you need to do browser
sniffing. Is it *really* necessary for what you are trying to
achieve?
It’s not *really* necessary, but without it, the users of IE6.0 can’t
select anything on http://student.ugent.be/astrid/bewoners.php
(strange, but with IE5.x it worked), just because I had the following
on top of my webpage:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

So I needed code that omitted the DOCTYPE when IE was used and that’s
how I stumbled across get_browser. Of course, I have to other options
that don’t need the browser sniffing:

(1) I just ignore the IE users. But although I really dislike IE (not
because it’s from Microsoft, but because IE doesn’t evolve together
with the webstanders), I can’t ignore those users :-/.

(2) I *always* omit the DOCTYPE. But then my page isn’t W3C compliant.

(3) Learn a bit more about the IE6 DOCTYPE switch and adapt your Javascript
or CSS (which probably causes the trouble) accordingly:
http://msdn.microsoft.com/library/en…ments.asp?fram
e=true#cssenhancements_topic2

(1) When I didn’t had any Javascript on my website, I didn’t had the
problem => JavaScript doesn’t cause the trouble

(2) The CSS-file validates correctly
(http://jigsaw.w3.org/css-validator/v…re%2Fnieuw.css)
=> CSS doesn’t cause the trouble (or it should be that the w3c validator
is wrong). I appreciate the link that you gave me, but it’s too much
work to read through the msdn, mozilla, khtml and opera pages to see how
they handle their pages, that’s why I (mostly) only check if the
(html/CSS)page validates correctly with the w3c and that’s (in my humble
opinion) the way it should be.
BTW, I am not sure what you mean by ‘select’ in your statement above — the
page works equally to me on IE6 and Firefox.

That’s because I already omitted the DOCTYPE through some browser
sniffing, now I included it again, so you can see it doesn’t work on
IE6: http://student.ugent.be/astrid/bewoners.php
If it behave differently on IE5, then the problem is not in PHP, but your
HTML/CSS/Javascript.

In my opinion, that’s a little bit to fast for a conclusion, I think
it’s a problem in IE6 😉

Greetings,
Mattias

A(Answer):

Chris Hope schreef:

Mattias Campe wrote:

However, I would implore you to consider why you need to do browser
sniffing. Is it *really* necessary for what you are trying to achieve?

It’s not *really* necessary, but without it, the users of IE6.0 can’t
select anything on http://student.ugent.be/astrid/bewoners.php (strange,
but with IE5.x it worked), just because I had the following on top of my
webpage:

I’m not sure if browser sniffing is your best solution but if you really
must do it, if the $_SERVER[‘HTTP_USER_AGENT’] contains ‘MSIE 6.0’ and does
not contain ‘Opera’ then it’s extremely likely to be IE 6.0

That was the way I did it first, but then I stumbled across the
get_browser() function and it seemed to be a more clean solution. That’s
why I asked on this newsgroup.

Mattias

LEAVE A COMMENT