4

I read on this thread: Simplest way to detect a mobile device on how to know if the browser is a mobile device. the general code is this:

<?php include("Mobile_Detect.php"); include("demoData.php");
$detectIsMobile = new Mobile_Detect(); ?>

The problem is that I want to treat tablets (iPad & xoom).

I saw there that there is a isIpad() function that I have tested yet - but that still doesn't solve the difference between tablets and mobile phones.

Any idea?

thanks, Alon

Community
  • 1
  • 1
Alon
  • 7,298
  • 16
  • 55
  • 94

3 Answers3

4

Use

<?php
    if($detect->isTablet()){
        // any tablet
    }
?>

You can refer this page for more info http://code.google.com/p/php-mobile-detect/

Sid
  • 1,245
  • 2
  • 20
  • 44
  • @Arif Please Provide more details and please make sure that you follow all the guidelines in the given link. – Sid Nov 08 '12 at 15:51
2

The only way to do this is with a huge lookup table of User-Agent: strings.

get_browser() would probably be able to do what you want, but you would need to make sure that you keep the browscap file very up to date - new tablet models are being released on a weekly basis.

Alternatively there may some Javascript way to do it (although I don't know what that might be) but

  • you would still have to keep a very large lookup table updated
  • you should never rely on Javascript for any kind of functionality.
DaveRandom
  • 84,004
  • 11
  • 142
  • 168
0
$detect = new Mobile_Detect; 
$deviceType = ( $detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');
echo $deviceType;