get_browser not working

前端 未结 4 777
野性不改
野性不改 2020-12-11 04:14

it\'s not working.i mean i have many scripts to get ip and os but anyway get_browser is internal function and should work but its not.when i try to get a print_r on the func

相关标签:
4条回答
  • 2020-12-11 04:44

    from php.net:

    Note: In order for this to work, your browscap configuration setting in php.ini must point to the correct location of the browscap.ini file on your system. browscap.ini is not bundled with PHP, but you may find an up-to-date » php_browscap.ini file here. While browscap.ini contains information on many browsers, it relies on user updates to keep the database current. The format of the file is fairly self-explanatory.

    sounds like your browscap.ini isn't up to date.

    0 讨论(0)
  • 2020-12-11 04:57

    I wasted much time to learn how to use that func,

    While I finally understood that man should never use that function, it will kill your performance !!!

    try with/without get_browser to check the result.

    ab -c 100 -n 100 http://yourserver/
    

    use preg_match_all('/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i', $_SERVER['HTTP_USER_AGENT']) instead

    0 讨论(0)
  • 2020-12-11 04:58

    I’ve heard many people complain about how the function just doesn’t work on their site. If you take a careful look at the manual, you’ll notice the following notice further down:

    1. The first thing you need to do is to check if your system has browscap.ini installed and if not, can you do so by yourself. invoke the phpinfo() function. This will help you gather some information about your system:

    2. If browscap is not installed, then look for Configuration File (php.ini) Path. This is where your PHP configuration file is located and enable browscap settings.After you’re done, it should look something like this:

      [browscap]

      browscap = "D:\xampp\php\extras\browscap.ini"

    3. Restart your apache try the below code

      $browser = get_browser(null, true);

      print_r($browser);

    4. if still your get_browser() is not functioning proper there might be problem with your browscap.ini file. You can download the updated browscap.ini file from https://browsers.garykeith.com/downloads, and replace your browscap.ini will be located in /php/extras/browscap.ini

    5. Once you done, restart your apache again and execute the code.

    0 讨论(0)
  • 2020-12-11 05:06

    Make sure you have an up-to-date browscap file. Read the notes in the documentation of get_browser.

    If you're not a server administrator, check out phpbrowcap which implements the same functionality but makes it possible for you to use another broswcap file than the server-wide one.

    0 讨论(0)
提交回复
热议问题