本篇文章代码性能是用PHP判别客户端是PC仍是手机,具备肯定参考代价,感兴味的冤家能够理解一下。
function is_mobile(){ $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){ return false; } if($is_mac){ return true; } if($is_iphone){ return true; } if($is_android){ return true; } if($is_ipad){ return true; } }
相干教程:PHP视频教程
以上就是PHP判别客户端为PC仍是手机的具体内容,更多请存眷资源魔其它相干文章!
标签: php php开发教程 php开发资料 php开发自学 判断客户
版权声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。
抱歉,评论功能暂时关闭!