php判断手机端
都有可能。我用手机浏览器访问你的web应用,获取到我的就是移动端的,我用电脑访问,那获取到的自然就是pc端的。所以像ecshop这些开源的php产品,他有个程序判断客户端访问是移动端还是pc端,然后路由到不同的处理程序。
B. php判断手机电脑并且进行跳转
<?
$wap="手机地址";
$pc="pc地址";
ww($wap,$pc);
function ww($wap,$pc){
if(preg_match('/(blackberry|configuration\/携念耐辩春cldc|hp |hp-|htc |htc_|htc-|iemobile|kindle|midp|mmp|motorola|mobile|nokia|opera mini|opera |Googlebot-Mobile|YahooSeeker\/M1A1-R2D2|android|iphone|ipod|mobi|palm|palmos|pocket|portalmmm|ppc;|smartphone|sonyericsson|sqh|spv|symbian|treo|up.browser|up.link|vodafone|windows ce|xda |xda_)/i', $_SERVER['HTTP_USER_AGENT'高咐])){header("Location: $wap");
exit;
}else{header("Location: $pc");
exit;}
}
?>
C. ThinkPHP中判断是手机端还是电脑端访问的方法
一般是通过访问的时候请求来源的header头文件信息来进行判断的,譬如Android的手机访问的话一般都会在hedear头信息里面带上Android这样的信息,同理Iphone、windows phone都会带。
D. php如何判断页面是手机端还是pc端
PHP 有个手机检测的库很出名啊 Mobile-Detect
地址:https://packagist.org/packages/mobiledetect/mobiledetectlib
或者
<?php
functionisMobile(){
$useragent=isset($_SERVER['HTTP_USER_AGENT'])?$_SERVER['HTTP_USER_AGENT']:'';
$useragent_commentsblock=preg_match('|(.*?)|',$useragent,$matches)>0?$matches[0]:'';
functionCheckSubstrs($substrs,$text){
foreach($substrsas$substr){
if(false!==strpos($text,$substr)){
returntrue;
}else{
returnfalse;
}
}
}
$mobile_os_list=array('GoogleWirelessTranscoder','WindowsCE','WindowsCE','Symbian','Android','armv6l','armv5','Mobile','CentOS','mowser','AvantGo','OperaMobi','J2ME/MIDP','Smartphone','Go.Web','Palm','iPAQ');
$mobile_token_list=array('Profile/MIDP','Configuration/CLDC-','160×160','176×220','240×240','240×320','320×240','UP.Browser','UP.Link','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,$useragent);
if($found_mobile){
returntrue;
}else{
returnfalse;
}
}
if(isMobile())
echo'phone';
else
echo'pc';
?>
E. php判断访问来源是PC还是手机端
构造一个函数来判没薯断,帮你找了一下别人博客上写的:
functiongetBrowserType(){
$is_mobile=false;
$mobile_os_list=array('GoogleWirelessTranscoder','WindowsCE','WindowsCE','Symbian','Android','armv6l','armv5','Mobile','CentOS','mowser','AvantGo','OperaMobi','J2ME/MIDP','Smartphone','Go.Web','Palm','iPAQ');
$mobile_token_list=array('Profile/MIDP','Configuration/CLDC-','160×160','176×220','240×240','240×320','320×240','UP.Browser','UP.Link','SymbianOS','PalmOS','PocketPC','SonyEricsson','Nokia','BlackBerry','Vodafone','BenQ','Novarra-Vision','Iris','NetFront','HTC_','Xda_','SAMSUNG-SGH','Wapaka','DoCoMo','iPhone','iPod');
$is_mobile=false;
枯携者foreach($mobile_os_listas$key=>$value){
if(strpos($_SERVER['HTTP_USER_AGENT'],$value)){
隐贺$is_mobile=true;
}
}
foreach($mobile_token_listas$key=>$value){
if(strpos($_SERVER['HTTP_USER_AGENT'],$value)){
$is_mobile=true;
}
}
return$is_mobile;
}
F. php如何判断客户端是pc还是手机
//判断是否是手机
functionis_mobile()
{
$agent=strtolower($_SERVER['HTTP_USER_AGENT']);
$is_pc=(strpos($agent,'windowsnt'))?true:false;
$is_mac=(strpos($agent,'macos'))?true:false;
$is_iphone=(strpos($agent,'iphone'))?true:false;
$is_android=(strpos($agent,'android'))?true:false;
$is_ipad=(strpos($agent,'ipad'))?true:false;
if($is_pc){
returnfalse;
}
if($is_mac){
returntrue;
}
if($is_iphone){
returntrue;
}
if($is_android){
returntrue;
}
if($is_ipad){
returntrue;
}
}
G. PHP判断是手机端还是PC端 PHP判断是否是微信浏览器
判断是否是微信浏览器:
function is_weixin(){
if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false ) {
return true;//是微信浏览器。返回true
}
return false;//不是微信浏览器。返回false
}
判断手机或pc
function isMobile()
{
// 如果有HTTP_X_WAP_PROFILE则一定是移动设备
if (isset ($_SERVER['HTTP_X_WAP_PROFILE']))
{
return true;
}
// 如果via信息含有wap则一定是移动设备,部分服务商会屏蔽该信息
if (isset ($_SERVER['HTTP_VIA']))
{
// 找不到为flase,否则为true
return stristr($_SERVER['HTTP_VIA'], "wap") ? true : false;
}
// 脑残法,判断手机发送的客户端标志,兼容性有待提高
if (isset ($_SERVER['HTTP_USER_AGENT']))
{
$clientkeywords = array ('nokia',
'sony',
'ericsson',
'mot',
'samsung',
'htc',
'sgh',
'lg',
'sharp',
'sie-',
'philips',
'panasonic',
'alcatel',
'lenovo',
'iphone',
'ipod',
'blackberry',
'meizu',
'android',
'netfront',
'symbian',
'ucweb',
'windowsce',
'palm',
'operamini',
'operamobi',
'openwave',
'nexusone',
'cldc',
'midp',
'wap',
'mobile'
);
// 从HTTP_USER_AGENT中查找手机浏览器的关键字
if (preg_match("/(" . implode('|', $clientkeywords) . ")/i", strtolower($_SERVER['HTTP_USER_AGENT'])))
{
return true;
}
}
// 协议法,因为有可能不准确,放到最后判断
if (isset ($_SERVER['HTTP_ACCEPT']))
{
// 如果只支持wml并且不支持html那一定是移动设备
// 如果支持wml和html但是wml在html之前则是移动设备
if ((strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') !== false) && (strpos($_SERVER['HTTP_ACCEPT'], 'text/html') === false || (strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') < strpos($_SERVER['HTTP_ACCEPT'], 'text/html'))))
{
return true;
}
}
return false;
}
H. 网页怎么判断是电脑浏览还是手机终端
不同的网页判断基准不一样
一、php/html网页判断标准
1、php网页是根据用户访问的设备分辨率来判断是电脑浏览器或者是手机浏览器的。
2、例如php通过如下代码即可实现统计:
<?php
functioncheck_wap(){
if(isset($_SERVER['HTTP_VIA']))returntrue;
if(isset($_SERVER['HTTP_X_NOKIA_CONNECTION_MODE']))returntrue;
if(isset($_SERVER['HTTP_X_UP_CALLING_LINE_ID']))returntrue;
if(strpos(strtoupper($_SERVER['HTTP_ACCEPT']),"VND.WAP.WML")>0){
//Checkwhetherthebrowser/gatewaysaysitacceptsWML.
$br="WML";
}else{
$browser=isset($_SERVER['HTTP_USER_AGENT'])?trim($_SERVER['HTTP_USER_AGENT']):'';
if(empty($browser))returntrue;
$mobile_os_list=array('GoogleWirelessTranscoder','WindowsCE','WindowsCE','Symbian','Android','armv6l','armv5','Mobile','CentOS','mowser','AvantGo','OperaMobi','J2ME/MIDP','Smartphone','Go.Web','Palm','iPAQ');
$mobile_token_list=array('Profile/MIDP','Configuration/CLDC-','160×160','176×220','240×240','240×320','320×240','UP.Browser','UP.Link','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,$browser)||
checkSubstrs($mobile_token_list,$browser);
if($found_mobile)
$br="WML";
else$br="WWW";
}
if($br=="WML"){
returntrue;
}else{
returnfalse;
}
}
functioncheckSubstrs($list,$str){
$flag=false;
for($i=0;$i<count($list);$i++){
if(strpos($str,$list[$i])>0){
$flag=true;
break;
}
}
return$flag;
}
if(check_wap()){
echo"wap";
}else{
echo"web";
}
?>
二、javajavascript的判断标准:
1、JavaScript不管是判断电脑浏览器还是手机浏览器,都是通过User Agent 来判断;
2、以 javascript判断实力如下:
<coding-1lang="other">
<scripttype="text/javascript">
varbrowser={
versions:function(){
varu=navigator.userAgent,app=navigator.appVersion;
return{
trident:u.indexOf('Trident')>-1,//IE内核
presto:u.indexOf('Presto')>-1,//opera内核
webKit:u.indexOf('AppleWebKit')>-1,//苹果、谷歌内核
gecko:u.indexOf('Gecko')>-1&&u.indexOf('KHTML')==-1,//火狐内核
mobile:!!u.match(/AppleWebKit.*Mobile.*/)||!!u.match(/AppleWebKit/),//是否为移动终端
ios:!!u.match(/(i[^;]+;(U;)?CPU.+MacOSX/),//ios终端
android:u.indexOf('Android')>-1||u.indexOf('Linux')>-1,//android终端或者uc浏览器
iPhone:u.indexOf('iPhone')>-1||u.indexOf('Mac')>-1,//是否为iPhone或者QQHD浏览器
iPad:u.indexOf('iPad')>-1,//是否iPad
webApp:u.indexOf('Safari')==-1//是否web应该程序,没有头部与底部
};
}()
}
document.writeln("是否为移动终端:"+browser.versions.mobile);
document.writeln("ios终端:"+browser.versions.ios);
document.writeln("android终端:"+browser.versions.android);
document.writeln("是否为iPhone:"+browser.versions.iPhone);
document.writeln("是否iPad:"+browser.versions.iPad);
document.writeln(navigator.userAgent);
</script>
</coding>
I. PHP判断手机是IOS还是Android
<?php
if(strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone')||strpos($_SERVER['HTTP_USER_AGENT'], 'iPad')){
echo 'systerm is IOS';
}else if(strpos($_SERVER['HTTP_USER_AGENT'], 'Android')){
echo 'systerm is Android';
}else{
echo 'systerm is other';
}