Tp5 判断电脑手机端 自动切换

//判断是否是手机
function is_mobile()
{

$user_agent = $_SERVER[‘HTTP_USER_AGENT‘];
    $mobile_agents = Array("240x320","acer","acoon","acs-","abacho","ahong",
        "airness","alcatel","amoi","android","applewebkit/525","applewebkit/532",
        "asus","audio","au-mic","avantogo","becker","benq","bilbo","bird","blackberry",
        "blazer","bleu","cdm-","compal","coolpad","danger","dbtel","dopod","elaine",
        "eric","etouch","fly ","fly_","fly-","go.web","goodaccess","gradiente","grundig",
        "haier","hedy","hitachi","htc","huawei","hutchison","inno","ipad","ipaq","ipod",
        "jbrowser","kddi","kgt","kwc","lenovo","lg","lg2","lg3","lg4","lg5","lg7","lg8",
        "lg9","lg-","lge-","lge9","longcos","maemo","mercator","meridian","micromax","midp",
        "mini","mitsu","mmm","mmp","mobi","mot-","moto","nec-","netfront","newgen","nexian",
        "nf-browser","nintendo","nitro","nokia","nook","novarra","obigo","palm","panasonic",
        "pantech","philips","phone","pg-","playstation","pocket","pt-","qc-","qtek","rover",
        "sagem","sama","samu","sanyo","samsung","sch-","scooter","sec-","sendo","sgh-","sharp",
        "siemens","sie-","softbank","sony","spice","sprint","spv","symbian","tablet","talkabout",
        "tcl-","teleca","telit","tianyu","tim-","toshiba","tsm","up.browser","utec","utstar",
        "verykool","virgin","vk-","voda","voxtel","vx","wap","wellco","wig browser","wii",
        "windows ce","wireless","xda","xde","zte");
    $is_mobile = false;

foreach ($mobile_agents as $device) {
        if (stristr($user_agent, $device)) {
            $is_mobile = true;
            break;
        }
    }

return $is_mobile;

}

is_mobile();

if ( is_mobile() ) {
    Header("HTTP/1.1 301 Moved Permanently");
    define(‘BIND_MODULE‘,‘index‘);
    Header("Location: http://".$_SERVER["HTTP_HOST"].‘/index/index/index‘);
}else{
    Header("HTTP/1.1 301 Moved Permanently");
    define(‘BIND_MODULE‘,‘admin‘);
    Header("Location: http://".$_SERVER["HTTP_HOST"].‘/admin/index/index‘);
}

原文地址:https://www.cnblogs.com/liiu/p/12630645.html

时间: 2024-10-13 18:54:12

Tp5 判断电脑手机端 自动切换的相关文章

javascript判断访问终端,手机端自动跳转

在网页的顶部加入javascript判断代码: function checkserAgent(){ var userAgentInfo=navigator.userAgent; var userAgentKeywords=newArray("Android", "iPhone" ,"SymbianOS", "Windows Phone", "iPad", "iPod", "MQ

php 判断是否手机端还是pc端

来自:https://www.cnblogs.com/webenh/p/5621890.html 用手机访问PC端WWW域名的时候,自动判断跳转到移动端,用电脑访问M域名手机网站的时候,自动跳转到PC端,我们团队在开发erdaicms二代旅游CMS网站管理系统的时候(http://www.erdaicms.com),分别开发了PC端和手机端,需要实现,用手机访问PC端WWW域名的时候,自动判断跳转到移动端,用电脑访问M域名手机网站的时候,自动跳转到PC端,于是有了下面这个判断函数: 1 /*移动

通过代码实现自动判断是手机端还是PC端跳转

1 <!-- 2017/09/13 跳转手机页面 start by 小鬼PSer --> 2 <meta name="mobile-agent" content="format=html5;url=http://forbag.inrn.net/kh1m.aspx"> 3 <script type="text/javascript"> 4 var userAgentInfo = navigator.userAge

JS判断PC 手机端显示不同的内容

方法一: function goPAGE() { if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) { window.location.href="手机版地址"; } } else

thinkphp中怎么判断是手机端访问还是pc端访问?

1 function isMobile() 2 { 3 // 如果有HTTP_X_WAP_PROFILE则一定是移动设备 4 if (isset ($_SERVER['HTTP_X_WAP_PROFILE'])) 5 return true; 6 7 // 如果via信息含有wap则一定是移动设备,部分服务商会屏蔽该信息 8 if (isset ($_SERVER['HTTP_VIA'])) 9 { 10 // 找不到为flase,否则为true 11 return stristr($_SERV

WEB手机端 上下切换效果

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width,target-densitydpi=high-dpi,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1

html+css手机端自动适应

<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=2.0, user-scalable=yes" /> 在网页的<head>中增加以上这句话,可以让网页的宽度自动适应手机屏幕的宽度 其中: width=device-width :表示宽度是设备屏幕的宽度 height=device-hei

电脑手机端如何互传文件、图片、网址等

1.AirDroid 我的第一感觉就是AirDroid,手机安装APP,然后访问网页端之后,就可以直接访问手机文件了.尤其是大文件(视频等)互传特别方便.还有手机通知电脑提醒功能. 最牛的一个功能是电脑远程操纵手机,神奇的不行. 至于为什么不用,因为公司电脑短款被封,无法实现局域网内互传.同时免费版用户每月200M流量,很快就用完了,不充钱用不了,弃. 总结:大文件.电脑远程控制手机 2.PushBullet 第二个就是PushBullet了,最适合传文字和小文件(图片文档等).其实PushBu

js如何判断是手机端还是PC端访问

function isMobile(){ var sUserAgent= navigator.userAgent.toLowerCase(), bIsIpad= sUserAgent.match(/ipad/i) == "ipad", bIsIphoneOs= sUserAgent.match(/iphone os/i) == "iphone os", bIsMidp= sUserAgent.match(/midp/i) == "midp", b