Simplest way to detect a mobile device in PHP

后端 未结 15 2528
别跟我提以往
别跟我提以往 2020-11-22 05:12

What is the simplest way to tell if a user is using a mobile device to browse my site using PHP?

I have come across many classes that you can use but I was hoping fo

15条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-22 05:41

    Simply you can follow the link. its very simple and very easy to use. I am using this. Its working fine.

    http://mobiledetect.net/

    use like this

    //include the file
    require_once 'Mobile_Detect.php';
    $detect = new Mobile_Detect;
    
    // Any mobile device (phones or tablets).
    if ( $detect->isMobile() ) {
     //do some code
    }
    
    // Any tablet device.
    if( $detect->isTablet() ){
     //do some code
    }
    

提交回复
热议问题