get_browser() function in PHP


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, return_array)

Parameters

  • user − The name of HTTP user agent.

  • return_array − If this parameter is set to true, the function will return an array instead of an object.

Return

The get_browser() function returns object or array with information about browser of user.

Example

Note − The result will vary system to system.

Example

<?php
   echo $_SERVER['HTTP_USER_AGENT'];
   $browseeInfo = get_browser();
   print_r($browserInfo);
?>

Output

The following is the output.

Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/70.0.3538.110 Safari/537.36

Updated on: 30-Dec-2019

608 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements