PHP get_browser()Functions
Examples
Looks up the user's browscap.ini file and returns the capabilities of the user's browser:
<?php
echo $_SERVER['HTTP_USER_AGENT'];
$browser = get_browser();
print_r($browser);
?>
echo $_SERVER['HTTP_USER_AGENT'];
$browser = get_browser();
print_r($browser);
?>
Run Example »
Definition and Usage
The get_browser() function looks up the user's browscap.ini file and returns the capabilities of the user's browser.
Syntax
get_browser(user_agent,return_array)
| Parameters | Description |
|---|---|
| user_agent | Optional. Specifies the name of the HTTP user agent. Default is the value of $HTTP_USER_AGENT. You can bypass this parameter by setting NULL. |
| return_array | Optional. If this parameter is set to TRUE, the function returns an array instead of an object. |
Technical Details
| Return Value: | If successful, the function returns an object or an array containing information about the user's browser. If it fails, it returns FALSE. |
|---|---|
| PHP Version: | 4+ |
| Changelog: | In PHP 4.3.2, addedreturn_arrayparameter. |
PHP Misc Reference Manual Other Extensions