Page 1 of 1

get_browser not working

Posted: Wed Mar 05, 2008 11:23 am
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! :-)

Re: get_browser not working

Posted: Sat Mar 08, 2008 2:24 am
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 );