LoginSignup
7
7

More than 5 years have passed since last update.

FuelPHPでユーザーエージェント判定すると、iPadはmobiledeviceになっちゃうよ問題

Posted at

FuelPHPでユーザーエージェント判定する時、Agent::is_mobiledevice()使います。便利ですね。しかしながら、こいつ、iPadでアクセスするとtrue吐くんです。

なので、iPad用には、別の判定式持った方がいいよ、って話。以下、実装例。

agent.php
public static function is_pad()
{
    return preg_match('/'.implode('|', array('iPad')).'/i', static::$user_agent) ? true : false;
}

これで、Agent::is_pad()叩くと、iPadの場合true吐きますので、is_mobiledevice()の結果を上書きしてやればいいんじゃないかと思います。一応、「is_pad」としている通り、配列array('iPad')に適当なやつ追加すればそれも対象に含めてくれることと思います。

7
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
7