<?php
header("Content-type:text/html;charset=utf-8");
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;
}
if(is_mobile()){
header("Location:你的手机网址");
}else{
header("Location:你的电脑网址");
}
php判断是手机还是pc访问从而走不同url
时间: 2024-12-29 01:43:37
php判断是手机还是pc访问从而走不同url的相关文章
php判断是手机还是pc访问
$is_mobile = false; $mobile_os_list = array('Google Wireless Transcoder', 'Windows CE', 'WindowsCE', 'Symbian', 'Android', 'armv6l', 'armv5', 'Mobile', 'CentOS', 'mowser', 'AvantGo', 'Opera Mobi', 'J2ME/MIDP', 'Smartphone', 'Go.Web', 'Palm', 'iPAQ');
javascript如何判断是手机还是电脑访问本网页
1 var system ={}; 2 var p = navigator.platform; 3 system.win = p.indexOf("Win") == 0; 4 system.mac = p.indexOf("Mac") == 0; 5 system.x11 = (p == "X11") || (p.indexOf("Linux") == 0); 6 if(system.win||system.mac||syst
判断是手机还是电脑访问的代码  ;
判断是手机还是电脑访问的函数代码: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 public function whichpad() { //检测访问的系统及版本.浏览器版本等信息 $agent = strtolower($_SERVER['HTTP_USER_AGENT']); $is_iphone = (strpos($agent, 'iphone')) ? true : false; $is_android = (strpo
如何判断是手机或电脑访问web
移动设备越来越主流,有很多网站对手机访问并不是特别的友好.所以我们要另外的给手机客户分配针对手机web访问的界面.如何判断是手机还是电脑在访问呢? 首先手机访问时,会附带发送user-agent信息,这个信息里面会有手机号码信息.我们如果可以获取...算了,用脚趾头也会想到,这是属于用户个人隐私信息的,移动和联通公司肯定给屏蔽或加密了.除非你服务器IP是在他们的白名单上. 那么我们换其他方式,当手机通过代理服务器访问的时候,http头信息会毫无疑问的包含一个信息:via.这个信息提供了有价值的判
如何判断是手机还是电脑访问网站:
现在由于手机功能的强大,使用手机上网的用户越来越多,那么就需要判断用户是用何种客户端登陆的网站,如果使用的是电脑则使用电脑版本的网页,如果使用的手机则使用手机版本的网页,下面是一段能够判断是手机还是电脑的代码: function check() { var userAgentInfo=navigator.userAgent; var Agents =new Array("Android","iPhone","SymbianOS",&
js判断是手机还是PC端
有时接触一些手机上的适应,需要知道是pc 还是移动端 function IsPC() { var userAgentInfo = navigator.userAgent; var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"]; var flag = true; for (var v
根据浏览器头判断是手机还是电脑访问
当一个域名对应一个PC端和mobile端的网站时,我们需要根据浏览器的header头做跳转判断,最简单的就是通过js来实现: <script type="text/javascript"> var isOnPc=!(/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent)); if(isOnPc){ self.location="/pc/index.
php或js判断网站访问者来自手机或者pc端源码
很多时候也可以通过逻辑程序来进行判断,如PHP.JS是常用的两种识别访问设备类型的常用方法. 原理都是采用识别访问客户端的HTTP_USER_AGENT,然后进行关键字匹配进行确定设备类型,对于伪造HTTP头的就区分不出来了. 区分设备类型然后要做的就是能够针对不同设置显示出易于阅读的网页,具体可以研究响应式布局技术. 本文主要介绍如何通过php或js来识别终端类型. <?php class IsMobile { public static function isMobile() { $user
PHP 判断终端是手机还是电脑访问网站代码
用thinkphp做底层框架,判断客户是用pc访问还是手机访问的. <?php $platform = platform();//检测访问平台 //print_r($_SERVER);DIE; define('FILE_ROOT' , dirname(__FILE__)); define('APP_DEBUG' , true); define('__BUICK__' , true);// define('APP_PUBLIC_PATH' , '../Public'); define('THINK