get_browser not working

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
pagod
Forum Newbie
Posts: 5
Joined: Wed Mar 05, 2008 10:59 am

get_browser not working

Post by pagod »

hi,

i'm running an apache server on my Mac Mini running Mac OS X 10.4.11, with entropy's PHP 5.2.2 installed. i've tried to use function get_browser to perform browser identification, but it doesn't seem to be working properly :-\

i've checked the php.ini file, at first the browscap.ini was apparently not loaded, as the line containing the path to the file was commented out. it pointed to extra/browscap.ini, which didn't exist anyway. now i've activated the line, downloaded the php_browscap.ini file from http://browsers.garykeith.com/downloads.asp, and stored it as /usr/local/php5/lib/extra/php_browscap.ini
my php.ini now looks like this:

Code: Select all

 
[browscap]
browscap = extra/php_browscap.ini
 
however, i don't really know how i can be sure the file has been loaded properly... i've restarted the apache server, and got no error in my error_log. i've then written a short script to test it, and all i get is my user-agent string (i'm using the newest firefox version, so it should be recognized) and a message that browscap is available. here's what the script looks like:

Code: Select all

 
<?php
echo "user-agent: " . $_SERVER[ 'HTTP_USER_AGENT' ] . "\n\n<br>";
if( ini_get( "browscap" ) ) {
    echo "browscap is available<br>\n";
    $browser = get_browser( null, true );
    print_r( $browser );
}
else {
    echo "no browscap <!-- s:-( --><img src=\"{SMILIES_PATH}/icon_sad.gif\" alt=\":-(\" title=\"Sad\" /><!-- s:-( -->\n";
}
?>
 
and the output in my browser:

Code: Select all

 
user-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12
browscap is available
 
can anyone tell me what i'm doing wrong or what i should do to enable browscap and get results from get_browser?

thx in advance! :-)
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Re: get_browser not working

Post by anjanesh »

Is get_browser() returning a FALSE value ?

Code: Select all

$browser = get_browser( null, true );
if ($browser === FALSE)
 echo "get_browser returned FALSE"
else
 print_r( $browser );
 
Post Reply