Detect iPhone Browser

前端 未结 6 1014
离开以前
离开以前 2020-12-05 08:59

is there a script to detect, if the visitor use iphone (whatever it\'s browser, may iphone Safari, iPhone for Opera or etc.)?

Then will shutdown some some of my Java

6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-05 09:13

    //Detect special conditions devices
    $iPod    = stripos($_SERVER['HTTP_USER_AGENT'],"iPod");
    $iPhone  = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone");
    $iPad    = stripos($_SERVER['HTTP_USER_AGENT'],"iPad");
    $Android = stripos($_SERVER['HTTP_USER_AGENT'],"Android");
    $webOS   = stripos($_SERVER['HTTP_USER_AGENT'],"webOS");
    
    //do something with this information
    if( $iPod || $iPhone ){
        //browser reported as an iPhone/iPod touch -- do something here
    }else if($iPad){
        //browser reported as an iPad -- do something here
    }else if($Android){
        //browser reported as an Android device -- do something here
    }else if($webOS){
        //browser reported as a webOS device -- do something here
    }
    

提交回复
热议问题