serbanghita / Mobile-Detect

Mobile_Detect is a lightweight PHP class for detecting mobile devices (including tablets). It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.
http://mobiledetect.net
MIT License
10.52k stars 2.67k forks source link

Can i combine mobile OR tablets? #435

Closed alexherdea closed 1 year ago

alexherdea commented 9 years ago

Hi,

I am having an issue with MobileDetect. I would like to use it like this: if($detect->isMobile() OR $detect->isTablet() ) {}

so basicaly, i need to show something only for mobiles or tablets. Unfortunately, those togheter don't work, they work ok only separate. Is there a way the i can combine those two into one script?

Thanks

Ro: Salut, incerc sa afisez o functie doar pentru mobile sau tablete, insa scriptul pare sa nu stie sa excluda desktop. Insa, daca folosesc separat If mobile si separat If tablet, se descurca exact cum trebuie. Se pot combina cele doua intr-un singur script? Multumesc frumos

allan-ayamah commented 9 years ago

A tablet is also a mobile device. So $detect->isMobile() should work for what you are trying to obtain.

To target only phones do this instead: $detect->isMobile() && !$detect->isTablet()

alexherdea commented 9 years ago

Ok, thanks for the answer! I thought that ismobile si only for mobile phones. My bad!