当前位置:首页 » 编程语言 » wapphp

wapphp

发布时间: 2024-06-23 02:56:41

php如何判断用户通过手机wap访问还是电脑直接访问

PHP通过内置全局变量$_SERVER['HTTP_USER_AGENT']来获取用户信息,包括浏览器信息,操作系统等;判断是否是手机还是电脑终端访问,只需判断他的$_SERVER['HTTP_USER_AGENT']信息是否存在手机终端类型即可。示例如下:
<?php
//1.获取用户浏览器信息 等;
$user_agent = $_SERVER['HTTP_USER_AGENT'];

//2.列举常用手机终端类型
$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","iphone","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");

foreach ($mobile_agents as $device) {
if (stristr($user_agent, $device)) {
//手机访问
$is_mobile = true;
break;
}
}
//判断手机标识是否为真
if($is_mobile){
echo "手机访问!";
}else{
echo "电脑访问!";
}

?>

回答不容易,希望能帮到您,满意请帮忙采纳一下,谢谢 !

Ⅱ 请教大神,php网址参数是怎么传递的

wap.php这个文件叫做单入口文件,就是指所有的文件都要从这个文件进入,参数是等号后面的这个字符串,例如:一般都是通过$_GET['c']的到Group的,c一般是定义了你的文件夹,a一般是定义了你的文件名,也就是Group文件下的index文件

热点内容
忘记密码魅族手机如何清除数据 发布:2024-11-26 21:34:17 浏览:155
达内php视频 发布:2024-11-26 21:32:09 浏览:555
编译器分析 发布:2024-11-26 21:13:01 浏览:831
存储过程execute 发布:2024-11-26 21:11:02 浏览:255
石器时代合成脚本 发布:2024-11-26 20:57:07 浏览:939
漏油器密码怎么改密码 发布:2024-11-26 20:30:11 浏览:14
linux编码命令 发布:2024-11-26 20:23:13 浏览:801
密码加密工具 发布:2024-11-26 20:23:06 浏览:692
如何破解加密的wifi 发布:2024-11-26 20:10:29 浏览:431
c脚本检查 发布:2024-11-26 19:56:34 浏览:394