2010-12-12 73 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設置下載的文件)。

相關問題