跳转PHP判断手机访问


function is_mobile() {

$user_agent = $_SERVER[‘HTTP_USER_AGENT‘];
$mobile_agents = Array("240x320","acer","acoon","acs-","abacho","ahong","airness","alcatel","amoi","android","anywhereyougo.com","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;

}

时间: 2024-10-09 20:31:37

跳转PHP判断手机访问的相关文章

通过PHP自带的$_SERVER判断 手机访问网站自动跳转到手机版

需要有PC版网站和移动版网站,当手机访问域名的时候,通过PHP自带的$_SERVER判断浏览设备并跳转到移动版页面.如果是PC电脑打开网址,则不跳转直接访问pc版. 1 <?php 2 //php判断客户端是否为手机 3 $agent = $_SERVER['HTTP_USER_AGENT']; 4 if(strpos($agent,"NetFront") || strpos($agent,"iPhone") || strpos($agent,"MI

JS判断手机访问还是电脑端访问

记录一下~~~~~~ <script type="text/javascript"> (function(){ if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) { console.log('这是移动端'); }else{ console.log('这是PC端'); } }) </script> HTML5中使用 tel: 在手机访问点击时,可直接调用拨号功能,get有效

JS判断手机访问页面,根据手机访问或者PC访问跳转

当用户访问你网站时,如果是PC端访问,则不作处理,如果是手机或者平板访问,就跳转到自己定义的手机页面去,这个在做webapp的时候经常用到,把代码分享给大家,希望对大家有所帮助. 首先,你要在页面中引用一个jsuaredirect.js,js源码如下: function uaredirect(f){try{if(document.getElementById("bdmark")!=null){return}var b=false;if(arguments[1]){var e=windo

js判断手机访问跳转到手机站

if(navigator.platform.indexOf('Win32')!=-1){ //电脑网站     }else{         window.location.href="";  //手机网站      } 参考:http://jingyan.baidu.com/article/cdddd41c61823e53cb00e198.html

通过js判断手机访问跳转到手机站

第一种方法: <script> if(navigator.platform.indexOf('Win32')!=-1){ //pc //window.location.href="电脑网址"; }else{ //shouji window.location.href="手机网址"; } </script> 第二种方法: <script type="text/javascript"> function brows

【转】js判断手机访问网页

原理:原理有两个,第一:通过游览器(browser)判断是否是手机:第二:通过访问终端判断是否是手机(userAgent):但是通常考虑到兼容性,需要这两种原理同时使用:具体的实现如下: JS实现: 1 2 function checkBrowser(){ 3 var browser={ 4 versions:function(){ 5 var u = navigator.userAgent, app = navigator.appVersion; 6 return { 7 //移动终端浏览器版

java 判断手机访问还是电脑访问

import javax.servlet.http.HttpServletRequest;public class HttpRequestDeviceUtils { /**Wap网关Via头信息中特有的描述信息*/    private static String mobileGateWayHeaders[]=new String[]{    "ZXWAP",//中兴提供的wap网关的via信息,例如:Via=ZXWAP GateWayZTE Technologies,    &quo

php js 判断手机访问

<?php function isMobile(){ $useragent=isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; $useragent_commentsblock=preg_match('|\(.*?\)|',$useragent,$matches)>0?$matches[0]:''; function CheckSubstrs($substrs,$text){ foreach($subst

php判断手机访问还是电脑访问示例分享

示例一(推荐): <?php header("Content-type:text/html;charset=utf-8"); function isMobile(){ $useragent=isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; $useragent_commentsblock=preg_match('|\(.*?\)|',$useragent,$matches)>0?$m