冰豆网

分享网络精彩
bingdou.com.cn

自动判断pc 手机切换接口

时间:2023-03-17加入收藏

<?php
$agent = strtolower($_SERVER['HTTP_USER_AGENT']);
$is_pc = (strpos($agent, 'windows nt')) ? true : false;
$is_mac = (strpos($agent, 'mac os')) ? 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){            
   $a=1;
}        
if($is_mac){              
   $a=1;
}        
if($is_iphone){              
   $a=2;
}        
if($is_android){              
   $a=2;
}        
if($is_ipad){              
   $a=2;
}
if($a==1){
    if($_GET['url']){
    $url=$_GET['url'];
    header("Location: 【电脑端接口】$url");
    }
}
if($a==2){
    if($_GET['url']){
    $url=$_GET['url'];
    header("Location: 【手机端接口】=$url");
    }
}
 

打 赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

TGA: php 技巧

分享到:


官方微信二维码冰豆网官方微信公众号