Cannot get browscap to load on OSX no matter which version I use or where I put it

StackOverflow https://stackoverflow.com/questions/18252824

  •  24-06-2022
  •  | 
  •  

Domanda

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!

È stato utile?

Soluzione

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.

Altri suggerimenti

I gave you the instructions to solve your problem,I think this will help you. your file path was absolutely right but you forgot to remove the semicolon and the double quotations mark [browscap] ;browscap = /Applications/XAMPP/xamppfiles/etc/browscap.ini"

download the file by clicking the link and put it in the file path which I explains you below
http://tempdownloads.browserscap.com/stream.asp?PHP_BrowsCapINI

Yeah, it seems XAMPP on Mac OSX installs differently, and you don't specify the root directory. First, find the file 'php.ini' installed in the following location: /Applications/XAMPP/xamppfiles/etc/php.ini Second, 'php.ini' is write protected in this location, so copy it to desktop thus allowing you to alter it. From desktop open in TextEdit and look for text reading '[browscap]' (we'll come back to this). Third, download a copy of file 'php_browscap.ini' from the Browser Capabilies Project.

 Mac OSX (cont.) Fourth, change filename from 'php_browscap.ini' to 'browscap.ini'. Place a copy in the following location:** /Applications/XAMPP/xamppfiles/etc/extra/browscap.ini Fifth, now go back and update file 'php.ini' with the new location of 'browscap.ini' to read as follows: [browscap] browscap = /Applications/XAMPP/xamppfiles/etc/extra/browscap.ini Sixth, save 'php.ini' and copy from desktop back into original location: /Applications/XAMPP/xamppfiles­/etc/php.in
   Seventh, restart XAMPP. ** Note: I think the location of 'browscap.ini' may be somewhat arbitrary. What seems most important is the pathname that is listed in file 'php.ini' under [browscap] (in my case, browscap = /Applications/XAMPP/xamppfiles­/etc/extra/browscap.ini). Good luck fellow Mac XAMPP users!
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top