Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
627 views
in Technique[技术] by (71.8m points)

php - get_browser not working

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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:xamppphpextrasrowscap.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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...