php $_SERVER['HTTP_USER_AGENT'] 2

简介: //mobile  false pc   true no pc    function is_mobile(){        $agent = strtolower($_SERVER['HTTP_USER_AGENT']);        $is_pc = (strpos($agent, 'win...

//mobile  false pc   true no 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_linux =    (strpos($agent, 'linux')) ? true : false;
        $is_unix =    (strpos($agent, 'unix')) ? 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_linux){
              return  false;
        }
        
        if($is_unix){
              return  false;
        } */
        
        if($is_iphone){
              return  true;
        }
        
        if($is_android){
              return  true;
        }
        
        if($is_ipad){
              return  true;
        }
    }
    
    function infoAgent(){
        $agent = strtolower($_SERVER['HTTP_USER_AGENT']);
        return $agent;
    }
    
    function is_iphone(){
        $info = false;
        if(strpos(tecrm::infoAgent(), 'iphone')){
            $info = "iphone";
        }
        return $info;
    }
    
    function is_android(){
        $info = false;
        if(strpos(tecrm::infoAgent(), 'android')){
            $info = "android";
        }
        return $info;
    }
    
    function is_ipad(){
        $info = false;
        if(strpos(tecrm::infoAgent(), 'ipad')){
            $info = "ipad";
        }
        return $info;
    }

目录
相关文章
|
7月前
|
PHP Apache
PHP $_SERVER
PHP $_SERVER
21 0
|
9月前
|
PHP
php开发实战分析(4):php调用封装函数包含文件路径自适应不同目录的解决方案($_SERVER[‘DOCUMENT_ROOT‘]与__DIR__魔术常量)
php开发实战分析(4):php调用封装函数包含文件路径自适应不同目录的解决方案($_SERVER[‘DOCUMENT_ROOT‘]与__DIR__魔术常量)
132 0
|
9月前
|
关系型数据库 MySQL PHP
Window Server studyPro部署php环境mysql数据库配置遇见的问题
Window Server studyPro部署php环境mysql数据库配置遇见的问题
57 1
|
PHP
【laravel报错】You don‘t have permission to access /laravel/public/index.php on this server.
【laravel报错】You don‘t have permission to access /laravel/public/index.php on this server.
98 0
【laravel报错】You don‘t have permission to access /laravel/public/index.php on this server.
|
PHP
PHP $SERVER详解
PHP $SERVER详解
92 0
PHP $SERVER详解
|
Apache PHP Windows
PHP面试题:windows平台, Apache Http Server启动失败, 排错思路是什么?
PHP面试题:windows平台, Apache Http Server启动失败, 排错思路是什么?
108 0
|
Web App开发 消息中间件 测试技术
使用PHP Web Server监听MNS Topic消息
本文主要演示如何在阿里云Linux虚拟机环境下监听MNS Topic的消息,主要内容包括:Linux环境的准备、阿里云MNS控制台配置及测试验证。
1770 0
|
PHP
PHP错误:Forbidden You don't have permission to access / on this server.
原文:PHP错误:Forbidden You don't have permission to access / on this server. 今天老大让在xp下搭建一个FTP服务器,一波三折,最后终于在老大的帮助下搞定了。
4009 0
|
PHP Windows 安全
windows server 2003 IIS下配置PHP
在IIS下配置PHP,一共4大步骤。 步骤/方法   首先下载Windows的PHP安装包。随后将该包解压至C:\PHP。完成上面的步骤后,将C:\php目录下的php.ini-dist文件改名为php.ini,然后拷到C:\Windows目录下。
893 0