note 8265 deleted from function.get-browser by irc-html

From: Date: Mon, 21 Jan 2002 00:46:30 +0000
Subject: note 8265 deleted from function.get-browser by irc-html
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-25597@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 ########## &lt;?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> &lt;?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

« previous php.notes (#25597) next »