Jump to content

Recommended Posts

I am not sure if you notice this part
[quote]
Note: In order for this to work, your [url=http://us2.php.net/manual/en/ref.misc.php#ini.browscap]browscap[/url] configuration setting in php.ini must point to the correct location of the browscap.ini file on your system.

browscap.ini is not bundled with PHP, but you may find an [url=http://browsers.garykeith.com/downloads.asp]up-to-date php_browscap.ini[/url] file here.
[/quote]


if the get_browser() doesn't work on your server, you can use an alternative at http://alexandre.alapetite.net/doc-alex/php-local-browscap/
[quote]
it seems to me as though it is the same as $_SERVER[HTTP_USER_AGENT]. Is it not?
[/quote]

It uses the $_SERVER[HTTP_USER_AGENT] to get the browser info, but it also uses a database to fill in all the details, Here is a sample output

[quote]
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040803 Firefox/0.9.3

Array
(
    [browser_name_regex] => ^mozilla/5\.0 (windows; .; windows nt 5\.1; .*rv:.*) gecko/.* firefox/0\.9.*$
    [browser_name_pattern] => Mozilla/5.0 (Windows; ?; Windows NT 5.1; *rv:*) Gecko/* Firefox/0.9*
    [parent] => Firefox 0.9
    [platform] => WinXP
    [browser] => Firefox
    [version] => 0.9
    [majorver] => 0
    [minorver] => 9
    [css] => 2
    [frames] => 1
    [iframes] => 1
    [tables] => 1
    [cookies] => 1
    [backgroundsounds] =>
    [vbscript] =>
    [javascript] => 1
    [javaapplets] => 1
    [activexcontrols] =>
    [cdf] =>
    [aol] =>
    [beta] => 1
    [win16] =>
    [crawler] =>
    [stripper] =>
    [wap] =>
    [netclr] =>
)

[/quote]

as you can see, you'll get all the browser details such as the name, version, support for css, frames, javascript, java, etc etc.... (the support part is if the browser is capable, and not if the user have it turned on or off).
Yeah, but that is over kill and unnecessary. All I require is the browser type (Firefox) and the browser version (1.5.0.4).
I now know how to get it ($_SERVER[HTTP_USER_AGENT]). This is what I get in my FF, “Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4.” How do I only pull out parts of this code?

Insight:
I need this to determine the level of accesses the user is given based upon the browsers capability to display semi-transparent ping images.

More insight:
I am in the process of re-scripting my site with the feature of themes. This way the user has the ability to choose a theme and with that theme there will be new colors, new background, and new photos. Unfortunately, not all browsers have the ability to support the semi-transparency of ping images. This is not my concern, my concern is how to nitpick the response from the $_SERVER[] code.
In my php.ini file (located at C:\wamp\Apache2\bin),  this is the only thing about the browscap.ini
[browscap]
;browscap = extra/browscap.ini

I put my browscap.ini file in C:\wamp\Apache2\bin\extra
and used this script:
<?php $_SERVER['HTTP_USER_AGENT']; $browser = get_browser(null, true); $browser = $browser['parent']; echo $browser; ?>

this is the error message I always get:
Warning: get_browser() [function.get-browser]: browscap ini directive not set. in C:\wamp\www\Tests\alignment.php on line 1

What am I doing wrong? Why isnt it working?
Thanks, I no longer have the error message. However, I don't have any message.

This is the browscap file that I am useing (it was to big to post it):
http://browsers.garykeith.com/stream.asp?PHP_BrowsCapINI

It says it is a special browscap file and maybe thats why it doesnt show anything when I use:
<?php $_SERVER['HTTP_USER_AGENT']; $browser = get_browser(null, true); $browser = $browser['parent']; echo $browser; ?>

So how do I make this work? Maybe I just need a normal browscap.ini file but I cant find one...
[quote author=Daniel0 link=topic=99583.msg394449#msg394449 date=1152542617]
1. Did you rename it from php_browscap.ini to browscap.ini?
2. Where did you put it?
[/quote]
1.)Yes, I have renamed the file to browscap.ini
2.) I placed it in, "C:\wamp\Apache2\bin\extra". I have placed it in this file because the php.ini file points to, "[browscap] browscap = extra/browscap.ini"
I found another browscap.ini file. In the process of changing the files, I decided to try the code with out the browscap file and my results where the same, no errors or words. So something’s wrong here, and it’s probably my fault. Can’t any one help?
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.