php识别访问手机操作系统,并直接下载相应的安装包

<?phpheader("Content-Type:texthtml; charsetutf-8");if(get_device_type()ios){$ffhuanbaoba.ipa;header(appl

<?php
header("Content-Type:text/html; charset=utf-8");
if(get_device_type()=='ios'){
	$ff='huanbaoba.ipa';
	header('application/iphone');
	header('Content-Disposition:attachment;filename="huanbaoba.ipa"');
}else{
	$ff='huanbaoba.apk';
	header('application/vnd.android.package-archive');
	header('Content-Disposition:attachment;filename="huanbaoba.apk"');
	
}
readfile($ff); 
function get_device_type(){
	$agent = strtolower($_SERVER['HTTP_USER_AGENT']);
	$type = 'other';
	if(strpos($agent, 'iphone') || strpos($agent, 'ipad')){
		$type = 'ios';
	}
	if(strpos($agent, 'android')){
		$type = 'android';
	}
	return $type;
}

安卓已经测试通过了

ios未测试

发布者:admin,转转请注明出处:http://www.yc00.com/web/1740324154a4229245.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信