xampp browscap.ini存在,但仍然get_browser()给出奇怪的值

时间:2013-08-08 08:00:08

标签: php browser xampp browscap

在说它重复之前请阅读,我已正确完成了我的作业:) 我检查了其他帖子,但没有任何帮助:(


以下是已经处理的事情:

1。http://tempdownloads.browserscap.com/下载更新的php_browscap.ini 副本(使用'仅限PHP使用'版本的课程)

2。尝试了php_browscap.ini,lite_php_browscap.ini和full_php_browscap.ini 3. 将php.ini文件编辑为

[browscap]
;http://php.net/browscap
browscap = "C:\xampp\php\extras\full_php_browscap.ini"

4. 通过检查 php_info()

确认我更改了正确的php.ini文件

5。,是已删除 ; 来自'; browscap = .....'

6。重申了xampp服务器

7。尝试使用“进程监视器”检查任何文件访问错误 https://www.dropbox.com/s/loi8p0fkykzcndr/process_monitor.png

但仍然得到奇怪的值

Array ( [browser_name_regex] => §^.*$§ [browser_name_pattern] => * [comment] => Default Browser [browser] => Default Browser [version] => 0.0 [majorver] => 0 [minorver] => 0 [platform] => unknown [platform_version] => unknown [platform_description] => unknown [alpha] => [beta] => [win16] => [win32] => [win64] => [frames] => [iframes] => [tables] => [cookies] => [backgroundsounds] => [javascript] => [vbscript] => [javaapplets] => [activexcontrols] => [ismobiledevice] => [issyndicationreader] => [crawler] => [cssversion] => 0 [aolversion] => 0 [device_name] => unknown [device_maker] => unknown [renderingengine_name] => unknown [renderingengine_version] => unknown [renderingengine_description] => unknown ) 

请帮助我,我花了很多时间阅读这里发布的答案,试图在谷歌上找到解决方案,看到了NewBoston的视频

1 个答案:

答案 0 :(得分:0)

// Loads the class
require 'path/to/Browscap.php';
// Creates a new Browscap object (loads or creates the cache)
$bc = new Browscap('path/to/the/cache/dir');
// Gets information about the current browser's user agent
$current_browser = $bc->getBrowser();    
// Output the result
echo '<pre>'; // some formatting issues ;)
print_r($current_browser);

我们将删除评论'输出结果'下的最后一部分,以便您的代码看起来像这样......

 // Loads the class
require 'path/to/Browscap.php';
 // Creates a new Browscap object (loads or creates the cache)
  $bc = new Browscap('path/to/the/cache/dir');
 // Gets information about the current browser's user agent
 $current_browser = $bc->getBrowser();