PHP判断移动浏览或Web浏览,并执行相应的简单操作示例。
我只是需要它。我在网上找了很长时间了。功能以移动(){
根据美元= isset($ _server { 'http_user_agent ' }){ } _server美元'http_user_agent ':';
useragent_commentsblock美元= preg_match(' | (* | '),根据美元,$matches)> 0美元比赛{ 0 }:;
功能checksubstrs(substrs美元,$文本){
foreach($ substrs达substr)
如果(假)!= = strpos(合文本,在美元)){
返回true;
}
返回false;
}
mobile_os_list美元=阵列('ogle无线转码,'windows CE,'windowsce ','symbian ','android ','armv6l ','armv5 ','armv5 ','windows,X,T,T,T,T,H,R,D,D)。
mobile_token_list美元=阵列('profile / / CLDC MIDP的,'configuration -,'160×160,'176×220,'240×240,'240×320,'320×240,向上。浏览器,向上。链接,'symbianos ','palmos ','pocketpc ','sonyericsson,'nokia ','blackberry ','vodafone ','benq ','novarra-vision ','iris ','netfront ','htc_ ','xda_ ','samsung-sgh ','wapaka ','docomo ','iphone 'ipod');
found_mobile美元= checksubstrs(mobile_os_list美元,美元| | useragent_commentsblock)
checksubstrs(mobile_token_list美元美元,用户代理);
如果($ found_mobile){
返回true;
其他{ }
返回false;
}
}
如果(以移动()){
头('location: / /索引。APP。'/library/loader.php'); / /如果手机终端,执行跳转
}
别的{
头('location: / Web /索引。'/library/loader.php'); / /如果手机终端,执行跳转
}
上面的PHP决定移动浏览或Web浏览以及执行相应的操作是否简单。一个例子是,萧边分享了你的全部内容。我希望能给你一个参考,希望你能支持它。