Jump to content

Php 5.1 Get_browser, Useragent Must Be Specified


nachumk
 Share

Recommended Posts

Hi,I am running Apache 2.2.14 and PHP 5.31 on Windows XP 32 bit.I have been trying to use the PHP get_browser function with the browscap.ini file. I have installed and verified that browscap.ini is working. The strange thing is that when I call get_browser like this:$browser = get_browser($_SERVER['HTTP_USER_AGENT'], true);then it works, but if I call it like:$browser = get_browser(null, true);then it doesn't work (the $browser variable is set as if the user agent was an empty string).My understanding from the documentation is that null should use the http user agent in use. Can someone shed some light on this?Thank you,

Edited by nachumk
Link to comment
Share on other sites

That's odd, what does your complete code look like?
This is a simple testcase:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd"> <html lang="en-US"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8559-1"> </head> <body> <?phpecho "User Agent: " . $_SERVER['HTTP_USER_AGENT'] . "<br>";echo 'print_r(get_browser($_SERVER[\'HTTP_USER_AGENT\'], true));<br>';print_r(get_browser($_SERVER['HTTP_USER_AGENT'], true));echo '<br>print_r(get_browser(null, true))<br>';print_r(get_browser(null, true));?></html> The first print_r shows the proper values, the second one acts as if user agent is an empty string.I can't give a live demonstration as I'm not yet sure how to configure browscap.ini on my hosting site... (godaddy)Thanx,
Link to comment
Share on other sites

I just got a demo working on godaddy. This took me a while as I had to figure out how to get browscap working... modifying and learning to restart php on their servers.Anyhow interesting thing is the same php ini file is used both on my system locally and on my godaddy hosting and yet on godaddy it works fine and on my system it is broken. I can only assume there is an Apache setting related to setting headers that affects something... Very unclear.Any help would be appreciated in tracking this down.PS I also tested my local web server from a 3rd computer with this error, so it isn't only when testing locally (ie browser on web server, but also browser from 3rd system to my local web server).thanx,

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...