2

I am working on PHP 5.4.12 and I was trying to use get_browser(); function. But it is not working at all. I am getting the following error:

"Warning: get_browser(): browscap ini directive not set in C:\wamp\www\myfirstfile.php on line 4"

I first used browscap.ini present on my PC, then download one named php_browscap.ini, but both didn't work.

I am using wamp as my localhost. I set the location of browscap file in php.ini file:

[browscap]
; http://php.net/browscap
;browscap = "C:\wamp\bin\php\php5.4.12\php_browscap.ini"

Still it gives me that error I mentioned above.

My code:

<?php
$browser = get_browser(null,true);
print_r($browser);
?>
TN888
  • 7,659
  • 9
  • 48
  • 84
mfs
  • 3,984
  • 6
  • 32
  • 51

2 Answers2

12

You never enabled the option:

;browscap = "C:\wamp\bin\php\php5.4.12\php_browscap.ini"
^---- comment/disable

Remove the ;.

Marc B
  • 356,200
  • 43
  • 426
  • 500
  • 1
    Don't forget to restart the web server, and also check phpinfo() to make sure you edited the CORRECT .ini file. There can be many of them. phpinfo will tell you which one(s) were used. – Marc B Jul 25 '13 at 18:46
  • 1
    Thanks alot Mar B :) there were two php.ini files and i edited the wrong one. my program works now. thanku :) – mfs Jul 25 '13 at 20:01
  • Thanks for this reply. Works for me – Fokwa Best Jun 01 '20 at 14:51
0
wget http://browscap.org/stream?q=Lite_PHP_BrowsCapINI -O /etc/php/7.1/mods-available/browscap.ini

Restart your server

Iago Leão
  • 174
  • 8