get_browser()方法
可获取浏览器具有的功能。注意:为了能让该函数有效运作,需要在 php.ini 中配置的browscap,指向 browscap.ini 文件。browscap.ini 并未内置在PHP中,此处下载: » php_browscap.ini。
browscap.ini 内的信息会不定期更新,建议每隔一两年更新一次该文件。
配置:
1,下载php_browscap.ini文件。文件有三几种,不同文件包含的信息不一样,下面会详细介绍。找个适合自己的下载,放到服务器某个位置,记住路径,在php.ini中使用。假设为:/wwwroot/browser_cap/php_browscap.ini
2,打开php.ini,结尾添加代码,如下:
[browscap]
; https://www.php.net/manual/zh/misc.configuration.php#ini.browscap
browscap = "/wwwroot/browser_cap/php_browscap.ini"
三个版本的区别
php_browscap.ini 所展示内容
Array
(
[browser_name_regex] => ~^mozilla/5\.0 \(.*linux.*android.10;.*\) applewebkit.* \(.*khtml.*like.*gecko.*\) chrome/.* mobile safari/.* edga/119\..*$~
[browser_name_pattern] => Mozilla/5.0 (*Linux*Android?10;*) applewebkit* (*khtml*like*gecko*) Chrome/* Mobile Safari/* EdgA/119.*
[parent] => Edge 119.0 for Android
[comment] => Edge 119.0
[browser] => Edge
[browser_maker] => Microsoft Corporation
[version] => 119.0
[majorver] => 119
[platform] => Android
[ismobiledevice] => 1
[device_type] => Mobile Phone
[device_pointing_method] => touchscreen
[minorver] => 0
[istablet] =>
[crawler] =>
)
full_php_browscap.ini所展示内容
Array
(
[browser_name_regex] => ~^mozilla/5\.0 \(.*linux.*android.10;.*\) applewebkit.* \(.*khtml.*like.*gecko.*\) chrome/.* mobile safari/.* edga/119\..*$~
[browser_name_pattern] => Mozilla/5.0 (*Linux*Android?10;*) applewebkit* (*khtml*like*gecko*) Chrome/* Mobile Safari/* EdgA/119.*
[parent] => Edge 119.0 for Android
[platform_version] => 10.0
[comment] => Edge 119.0
[browser] => Edge
[browser_type] => Browser
[browser_bits] => 32
[browser_maker] => Microsoft Corporation
[version] => 119.0
[majorver] => 119
[platform] => Android
[platform_description] => Android OS
[platform_bits] => 32
[platform_maker] => Google Inc
[frames] => 1
[iframes] => 1
[tables] => 1
[cookies] => 1
[javascript] => 1
[ismobiledevice] => 1
[cssversion] => 3
[aolversion] => 0
[device_name] => general Mobile Phone
[device_type] => Mobile Phone
[device_pointing_method] => touchscreen
[device_code_name] => general Mobile Phone
[renderingengine_name] => Blink
[renderingengine_description] => a WebKit Fork by Google
[renderingengine_maker] => Google Inc
[browser_modus] => unknown
[minorver] => 0
[alpha] =>
[beta] =>
[win16] =>
[win32] =>
[win64] =>
[backgroundsounds] =>
[vbscript] =>
[javaapplets] =>
[activexcontrols] =>
[istablet] =>
[issyndicationreader] =>
[crawler] =>
[isfake] =>
[isanonymized] =>
[ismodified] =>
[device_maker] => unknown
[device_brand_name] => unknown
[renderingengine_version] => unknown
)
lite_php_browscap.ini所展示内容
Array
(
[browser_name_regex] => ~^mozilla/5\.0 \(.*linux.*android.*\) applewebkit.* \(.*khtml.*like.*gecko.*\) chrome/.* mobile safari/.* edga/119\..*$~
[browser_name_pattern] => Mozilla/5.0 (*Linux*Android*) applewebkit* (*khtml*like*gecko*) Chrome/* Mobile Safari/* EdgA/119.*
[parent] => Edge 119.0 for Android
[comment] => Edge 119.0
[browser] => Edge
[version] => 119.0
[platform] => Android
[ismobiledevice] => 1
[device_type] => Mobile Phone
[istablet] =>
)
评论区
发表新的留言
您可以留言提出您的疑问或建议。
您的留言得到回复时,会通过您填写的邮箱提醒您。