Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get_browser not working

Tags:

browser

php

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 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'm using win7 and firefox. And i have the latest browcap and set in php.ini.without that php returns error while idont get one.

like image 555
tazphoenix Avatar asked Jun 09 '10 05:06

tazphoenix


People also ask

How can I get current browser in PHP?

PHP get_browser() Function echo $_SERVER['HTTP_USER_AGENT']; $browser = get_browser(); print_r($browser);

What is a Browscap INI file?

Browscap. ini is a file, introduced with Microsoft's IIS, that lists the User-Agent strings that different browsers send, and various capabilities of those browsers. This module parses browscap. ini and allows you to find the capability definitions for a given browser.


1 Answers

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.

like image 157
Ashique CM Avatar answered Sep 18 '22 11:09

Ashique CM