gpt4 book ai didi

php - 使用 PHP 检测股票 android 浏览器?

转载 作者:太空狗 更新时间:2023-10-29 16:16:14 28 4
gpt4 key购买 nike

正如你们中的许多人可能遇到的那样,幸好在 Android 4.4 中停产的普通 Android 浏览器或多或少是现代的 IE6 - 漏洞百出,严重到导致开发人员自杀的地步。因此,为该浏览器提供特定资源的需求正迅速成为一种必需,而实现这一点的最佳方法是通过后端链接样式表/js。那么使用 PHP 检测浏览器的万无一失的方法是什么?

最佳答案

谢天谢地,这很简单:

//get the user agent string
$ua = $_SERVER['HTTP_USER_AGENT'];

//results array
$matches = [];

//perform regex query
preg_match ( '/Android.*AppleWebKit\/([\d.]+)/', $ua, $matches);

//Check if the regex query returned matches specific to
//the android stock browser.
if( isset($matches[0]) &&

//This is where we diffrentiate the stock browser from chrome,
//the default browser's webkit version never goes above 537
( isset($matches[1]) && intval($matches[1] < 537) ) ){
echo 'Browsing via stock android browser';
}

请添加您改进的答案。

关于php - 使用 PHP 检测股票 android 浏览器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26528668/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com