3

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);
?>
2

2 Answers 2

13

You never enabled the option:

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

Remove the ;.

3
  • 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, 2013 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, 2013 at 20:01
  • Thanks for this reply. Works for me
    – Fokwa Best
    Jun 1, 2020 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.