且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

php中判断iphone版本

更新时间:2022-08-13 10:16:01

引用:http://bbs.php100.com/read-htm-tid-428301.html

下面这个是能判断的,但是出现一个问题,就是ios版本的UC浏览器出现了一个极速模式,切换到了极速模式就判断不出来了。现在想单独判断UC浏览器下进行跳转。

    1. $userAgent = $_SERVER['HTTP_USER_AGENT'];
    2. if(strpos($userAgent,"iPhone") || strpos($userAgent,"iPad") || strpos($userAgent,"iPod")){
    3.     header("location:http://www.baidu.com");
    4. }else if(strpos($userAgent,"Android")){
    5.     header("location:http://www.google.com");
    6. }
      1. 解决了 原来在UC里面没有iPhone\iPad\iPod相关字样,加一个
        1. strpos($userAgent,"iPhone") || strpos($userAgent,"iPad") || strpos($userAgent,"iPod")

        改成
        1. strpos($userAgent,"iPhone") || strpos($userAgent,"iPad") || strpos($userAgent,"iPod") || strpos($userAgent,"iOS")


        就可以了