PHP code example of tekintian / uadetect

1. Go to this page and download the library: Download tekintian/uadetect library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tekintian / uadetect example snippets


// Check for mobile environment.
if ($detect->isMobile()) {
    // Your code here.

// Check for tablet device.
if($detect->isTablet()){
    // Your code here.

// Check for any mobile device, excluding tablets.
if ($detect->isMobile() && !$detect->isTablet()) {
    // Your code here.

//  Keep the value in $_SESSION for later use
//    and for optimizing the speed of the code.
if(!$_SESSION['isMobile']){
    $_SESSION['isMobile'] = $detect->isMobile();

// Redirect the user to your mobile version of the site.
if($detect->isMobile()){
    header('http://m.yoursite.com', true, 301);

// Include and instantiate the class.
mobile device (phones or tablets).
if ( $detect->isMobile() ) {