What is the usage of php get_browser

藏色散人
Release: 2023-03-12 15:34:01
Original
1302 people have browsed it

php get_browser function can measure the performance of the user's browser by consulting the user's browscap.ini file. Its usage syntax is "get_browser(user_agent,return_array)".

What is the usage of php get_browser

The operating environment of this article: Windows7 system, PHP7.1 version, Dell G3 computer

php get_browser usage

The get_browser() function returns the performance of the user's browser.

This function measures the performance of the user's browser by consulting the user's browscap.ini file.

If successful, this function returns an object or an array containing the user's browser information. If it fails, it returns false.

Syntax

get_browser(user_agent,return_array)
Copy after login

Parameters

user_agent

Optional. Specifies the name of the HTTP user agent. The 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, this function returns an array instead of an object.

Tips and Notes

Note: The return statement immediately terminates the evaluation of the string.

Note: This function is useful for storing code in a database text field for later calculations.

Example

<?php
echo $_SERVER[&#39;HTTP_USER_AGENT&#39;] . "<br /><br />";
$browser = get_browser(null,true);
print_r($browser);
?>
Copy after login

Output:

Mozilla/4.0
(compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)
Array
(
[browser_name_regex] => ^mozilla/.\.0
(compatible; msie 6\.0.*;.*windows nt 5\.1.*\.net clr.*).*$
[browser_name_pattern] => Mozilla/?.0
(compatible; MSIE 6.0*;*Windows NT 5.1*.NET CLR*)*
[parent] => IE 6.0
[platform] => WinXP
[netclr] => 1
[browser] => IE
[version] => 6.0
[majorver] => 6
[minorver] => 0
[css] => 2
[frames] => 1
[iframes] => 1
[tables] => 1
[cookies] => 1
[backgroundsounds] => 1
[vbscript] => 1
[javascript] => 1
[javaapplets] => 1
[activexcontrols] => 1
[cdf] => 1
[aol] =>
[beta] =>
[win16] =>
[crawler] =>
[stripper] =>
[wap] =>
[ak] =>
[sk] =>
)
Copy after login

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What is the usage of php get_browser. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template