I am trying to get the following code to run:
$browser = get_browser(null, true);
print_r($browser);
The error that I get is as follows:
Warning: get_browser() [function.get-browser]: browscap ini directive not set in /Applications/XAMPP/xamppfiles/htdocs/series/firstfile/index.php on line 3
I am running OSX 10.8.4 with XAMPP. The browscap info in my php.ini file is as follows:
[browscap]
;browscap = /Applications/XAMPP/xamppfiles/etc/browscap.ini"
I have also tried the following paths:
/Macintosh HD/Applications/XAMPP/xamppfiles/etc/browscap.ini
I downloaded and placed the browscap.ini
file myself into that directory and have also tried referencing it from other locatations in case it was a permission issue or something.
I am assuming that the problem is with how I write my path but I just cant find a way to get XAMPP to accept it and when you go to phpinfo()
it is listed under 'core'
as browscap - no value
.
Obviously I have been restarting Apache etc. with each change to ensure that the php.ini
is refreshed.
All of the information I can find seem to pertain to Windows rather than Mac so I am struggling!
I wonder what kind of valuable information you expect to get from this function.
But whatever it is, please be advised that it is considered bad practice, because you are essentially practicing server based client sniffing, and the only base of information is the user agent string, which can be anything and does not need to represent the real situation. Also, information like "javascript" can only represent the coded ability of the client, not the current configured abilities, which can be less.
If you still think the function to be of any use, you have to solve the task of getting a copy of that "browscap.ini" file this function wants to use, and you have to constantly update this file to include new browser versions.
There is a link to a file source on the documentation page of
get_browser()
. Download a file and point the INI setting to that location. Make sure to activate it by removing the semikolon.