xRobot
xRobot

Reputation: 26567

Is there a simple way to get only the Browser and the OS?

I need to detect the browser and the OS in a way like this:

Browser: Chrome 8
OS:      Ubuntu 10.04

I have tryed this but doesn't work:

<?php

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

?>

I get this error:

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

Upvotes: 2

Views: 275

Answers (3)

hobbs
hobbs

Reputation: 239781

The error and the documentation are there to be read, not ignored. Install a browscap.ini, configure its location, and try again.

Upvotes: 2

Here you will find the required php_browscap.ini file (and you will also need to point the browscap setting in php.ini to the downloaded file).

Upvotes: 1

Sarfraz
Sarfraz

Reputation: 382666

The error message shows that you have not configured settings for get_browser to work.

Quoting:

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

Upvotes: 1

Related Questions