note 8265 added to get_browser

From: Date: Sun, 03 Sep 2000 04:02:43 +0000
Subject: note 8265 added to get_browser
Groups: php.notes 
Request: Send a blank email to php-notes+get-3977@lists.php.net to get a copy of this message
all -- I have played around a bit with get_browser() and the browscap.ini file recommended in the FAQ. get_browser() does seem to have a bug. If there is no matching browser pattern in browscap.ini then get_browser() fails. I added an entry like so to the very tail of the browscap.ini file: ;;;;;;;;;;;; cut here ;;;;;;;;;;;; [*] parent=Default Browser Capability Settings ; ;;; cut here ;;;;;;;;;;;;;; Note the trailing ';' ( for the Solaris core dump I read about ;-) At least now when get_browser() encounters an undefinde HTTP_USER_AGENT, it will report something. I also wrote a small php3 script as follows: ############# cut here ########## <?php $array = get_Browser (); ?> <html> <head> <title>Which Browser ?</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#FFFFFF"> <H2><CENTER>Which Browser do you run?</CENTER></H2> <p> <center> <?php print "You seem to be running a " . $HTTP_USER_AGENT . " browser"; if ( empty ( $array )) { echo "<br><br>get_browser() did not work!" ; } else { echo "<br><br>" ; echo "<table border=2>" ; echo "<tr><th align=right>Key</th><th align=left>Value</th></tr>\n" ; while ( list ( $key, $value ) = each ( $array )) { if ( empty ( $value )) $value = "not set" ; echo "<tr><td align=right>$key</td><td align=left>$value</td></tr>\n" ; } echo "</table>" ; } ?> </center> </p> </body> </html> ############### cut here ############# The output at the top of the script showed me what browser_pattern to add to browscap.ini. ( sheesh, gotta love this text box for entering scripts ;-) HTH. -- kjh http://www.php.net/manual/function.get-browser.php

« previous php.notes (#3977) next »