get_browser
Tells what the user's browser is capable of.
get_browser Function synopsis
get_browser(?string $user_agent = null, bool $return_array = false): object|array|false
Parameters
$user_agent
OptionalType?stringDefault valuenull
The User Agent to be analyzed. By default, the value of HTTP User-Agent header is used; however, you can alter this (i.e., look up another browser's info) by passing this parameter.
$return_array
OptionalTypeboolDefault valuefalse
If set to true, this function will return an array
instead of an object.
Return value
Typeobject|array|false
The information is returned in an object or an array which will contain
various data elements representing, for instance, the browser's major and
minor version numbers and ID string; true/false values for features
such as frames, JavaScript, and cookies; and so forth.
The cookies value simply means that the browser
itself is capable of accepting cookies and does not mean the user has
enabled the browser to accept cookies or not. The only way to test if
cookies are accepted is to set one with setcookie,
reload, and check for the value.
Returns `false` when no information can be retrieved, such as when the
[`browscap`](/codex/ini-browscap)configuration setting in
`php.ini` has not been set. Changes to the get_browser Function
PHP 8.0
- Return type added:
object|array|false - Parameter name of parameter #1 changed:
$browser_nameto$user_agent - Parameter type added for parameter #1 (
$user_agent):?string - Parameter default value added for position #1 (
$user_agent):null - Parameter type added for parameter #2 (
$return_array):bool - Parameter default value added for position #2 (
$return_array):false
- get_browser($browser_name, $return_array)
+ get_browser(?string $user_agent = null, bool $return_array = false): object|array|false get_browser Function Availability
get_browser Function Availability| PHP Version | Availability |
|---|---|
| PHP 8.6Upcoming Release | Yes |
| PHP 8.5Supported (Latest) | Yes |
| PHP 8.4Supported | Yes |
| PHP 8.3Security-Fixes Only | Yes |
| PHP 8.2Security-Fixes Only | Yes |
| PHP 8.1Unsupported | Yes |
| PHP 8.0Unsupported | Yes |
| PHP 7.4Unsupported | Yes |
| PHP 7.3Unsupported | Yes |
| PHP 7.2Unsupported | Yes |
| PHP 7.1Unsupported | Yes |
| PHP 7.0Unsupported | Yes |
| PHP 5.6Unsupported | Yes |
| PHP 5.5Unsupported | Yes |
| PHP 5.4Unsupported | Yes |
| PHP 5.3Unsupported | Yes |