Class for identifying devices

Rizwan

Moderator
Staff member
When writing scripts, many beginners and others have the problem of identifying devices
on the off-site , there is a ready-made class, below we show how to use it

Code:
<? php

//connect the class
require_once 'Mobile_Detect.php' ;
$detect = new Mobile_Detect ; 
 
if ( $detect -> isMobile ()){
     echo "mobile content" ; }

 
if ( $detect -> isTablet ()){
     echo "tablet content" ; }

 
if (! $detect -> isMobile () && ! $detect -> isTablet ()){
     echo "content for computers" ; } 

 
if ( $detect -> isiOS ()){
     echo "for iOS" ; }

 
if ( $detect -> isAndroidOS ()){
     echo "for Android" ; }

 
if ( $detect -> is ( 'UC Browser' )){
     echo "tablet for UC browser" ; }

So you can use this class for different purposes
for example

Code:
if ( $detect -> isMobile ()){
     echo "<link rel='stylesheet' href='mobile.css'>" ; }

I’ll help with the installation, please contact us in a personal
thank you for your attention
 
Back
Top