2010-12-12 68 views
2

我需要检测浏览器和操作系统中像这样的方式:有没有简单的方法来获取浏览器和操作系统?

Browser: Chrome 8 
OS:  Ubuntu 10.04 

我已经tryed这一点,但不起作用:

<?php 

$browser = get_browser(null, true); 
echo "Browser: ".$browser['parent'] 
echo "OS: ".$browser['platform'] 

?> 

我得到这个错误:

Warning: get_browser() [function.get-browser]: browscap ini directive not set in /opt/lampp/htdocs/info.php on line 8

回答

2

错误和the documentation需要阅读,而不是忽略。安装browscap.ini,配置其位置,然后重试。

1

错误消息显示您尚未配置get_browser的设置以使其工作。

报价:

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.

http://php.net/manual/en/function.get-browser.php

1

Here你会发现所需php_browscap.ini文件(你还需要在php.ini来点browscap设置下载的文件)。

相关问题