Get_browser not working

he does not work. I mean, I have many scripts for getting ip and os, but in any case, get_browser is an internal function and should work, but it doesn’t. When I try to get print_r on the function I get.

Array ( [browser_name_regex] => §^.*$§ [browser_name_pattern] => * [browser] => Default Browser [version] => 0 [majorver] => 0 [minorver] => 0 [platform] => unknown [alpha] => [beta] => [win16] => [win32] => [win64] => [frames] => 1 [iframes] => [tables] => 1 [cookies] => [backgroundsounds] => [cdf] => [vbscript] => [javaapplets] => [javascript] => [activexcontrols] => [isbanned] => [ismobiledevice] => [issyndicationreader] => [crawler] => [cssversion] => 0 [supportscss] => [aol] => [aolversion] => 0 ) 

I am using win7 and firefox. And I have the last browcap and set to php.ini.without that php returns an error and idont gets one.

+7
browser php
source share
4 answers

Ive heard many people complain about how the feature just doesn't work on their site. If you carefully study the manual, you will notice the following below:

  • The first thing you need to do is check if your system is installed by the browser, and if not, can you do it yourself. call the phpinfo () function. This will help you gather information about your system:

  • If the browser is not installed, find the Configuration File (php.ini). Here you will find your PHP configuration file and enable browser settings. After that you should look something like this:

    [browscap]

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

  • Restart apache using the code below.

    $ browser = get_browser (null, true);

    print_r ($ browser);

  • if your get_browser () is not working properly, there may be a problem with your browsercap.ini file. You can download the updated browscap.ini file from https://browsers.garykeith.com/downloads , and your browser.ini will be replaced by your browser in /php/extras/browscap.ini

  • Once you do this, restart apache and execute the code.

+13
source share

Make sure you have an updated browser file. Read the notes in the get_browser documentation.

If you are not a server administrator, check out phpbrowcap , which implements the same functionality but allows you to use a different broswcap file than the server one.

+9
source share

from php.net :

Note. . For this to work, the cast configuration setting in php.ini must point to the correct location of the browsercap.ini file on your system. browscap.ini is not bundled with PHP, but you can find the updated "php_browscap.ini file here. Although browsercap.ini contains information about many browsers, it relies on custom updates to keep current. The file format is pretty clear.

It sounds like your browser browser is not updated.

+6
source share

I spent a lot of time to learn how to use this func,

Until I finally realized that a person should never use this function, he will kill your productivity !!!

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

+1
source share

All Articles