Giter Site home page Giter Site logo

serbanghita / mobile-detect Goto Github PK

View Code? Open in Web Editor NEW
10.5K 596.0 2.7K 4.23 MB

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.

Home Page: http://mobiledetect.net

License: MIT License

PHP 99.77% Shell 0.23%
mobile-detect device-detection user-agents php mobile-redirects

mobile-detect's Introduction

Mobile Detect

MobileDetect, PHP mobile detection class

Workflow status Latest tag Monthly Downloads Total Downloads MIT License

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.

Before you install

There are three versions of MobileDetect. 4.8.x is the main version that is ALWAYS going to be updated first.

Version Tests Namespace Code PHP Version Status
2.8.x 5x \Mobile_Detect 2.8 >=5.0,<7.0 Deprecated
3.74.x 7x Detection\MobileDetect 3.74 >=7.4,<8.0 LTS
4.8.x 7x Detection\MobileDetect 4.8 >=8.0 Current, Recommended

🀝 Supporting

If you are using Mobile Detect open-source package in your production apps, in presentation demos, hobby projects, school projects or so, you can sponsor my work by donating a small amount πŸ‘. I'm currently paying for hosting and spend a lot of my family time to maintain the project and planning the future releases. I would highly appreciate any money donations.

Special thanks to:

  • the community πŸ‘ for donations, submitting patches and issues
  • the JetBrains team for the open-source licenses for PHPStorm IDE
  • Gitbook team for the open-source license for their technical documentation tool.

πŸ“ƒ Documentation

The entire documentation is available on Gitbook: https://docs.mobiledetect.net

πŸ‘Ύ Demo

Point your device to: https://demo.mobiledetect.net

πŸ› Testing

vendor/bin/phpunit -v -c tests/phpunit.xml --coverage-html .coverage

🀝 Contributing

Please see the Contribute guide for details.

πŸ”’ Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

πŸŽ‰ Credits

mobile-detect's People

Contributors

bhamodi avatar blankse avatar carusogabriel avatar darapa1 avatar deviavir avatar eidng8 avatar eugenyp avatar garthi avatar h3xx avatar hainuo avatar hpbuniat avatar jbinfo avatar jenssegers avatar julienbornstein avatar lxlang avatar mbezhanov avatar mikebe11 avatar nextend avatar nicktacular avatar ossinkine avatar readmecritic avatar serbanghita avatar sergeifilippov avatar sheldon avatar simonschaufi avatar spmartin823 avatar staabm avatar tluan95 avatar vlakoff avatar yangmin449 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mobile-detect's Issues

Internet Explorer

isIE does not work. I tested it with internet explorer on my laptop but it did not detect on all versions of IE. can you help?

Android Bugz

I have 2 bugs:

  • on the stock browser it returns isSafari(true) wich is false

Android Stock

  • and on chrome browser it retuns isChrome(true) and isSafari(true)

Android Chrome

Tablet RegEx Order

I see in your code that you loop through the tablet regexs, but you have BlackBerry tablet at #1 on the list. I would think for the fastest code possible, you would want to order that list from most popular to least popular .. is BlackBerry tablet really more popular than Ipad, Nexus or even Kindle??

is_Tablet() to be different then is_Mobile()

On my site I need to render things differently on Tablets vs Mobile.

If I use is_Mobile() this affects the items on the tablet. Is there a way to make it so that is_Mobile does not affect tablets?

isChrome() fails

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11

Supported methods

Basic detection methods
isMobile() bool(false)
isTablet() bool(false)
Custom detection methods
isiPhone() bool(false)
isBlackBerry() bool(false)
isHTC() bool(false)
isNexus() bool(false)
isDell() bool(false)
isMotorola() bool(false)
isSamsung() bool(false)
isSony() bool(false)
isAsus() bool(false)
isPalm() bool(false)
isVertu() bool(false)
isGenericPhone() bool(false)
isBlackBerryTablet() bool(false)
isiPad() bool(false)
isNexusTablet() bool(false)
isKindle() bool(false)
isSamsungTablet() bool(false)
isHTCtablet() bool(false)
isMotorolaTablet() bool(false)
isAsusTablet() bool(false)
isNookTablet() bool(false)
isAcerTablet() bool(false)
isYarvikTablet() bool(false)
isMedionTablet() bool(false)
isArnovaTablet() bool(false)
isArchosTablet() bool(false)
isAinolTablet() bool(false)
isSonyTablet() bool(false)
isGenericTablet() bool(false)
isAndroidOS() bool(false)
isBlackBerryOS() bool(false)
isPalmOS() bool(false)
isSymbianOS() bool(false)
isWindowsMobileOS() bool(false)
isWindowsPhoneOS() bool(false)
isiOS() bool(false)
isFlashLiteOS() NULL
isMeeGoOS() bool(false)
isMaemoOS() bool(false)
isJavaOS() bool(false)
iswebOS() bool(false)
isbadaOS() bool(false)
isBREWOS() bool(false)
isChrome() bool(false)
isDolfin() bool(false)
isOpera() bool(false)
isSkyfire() bool(false)
isIE() bool(false)
isFirefox() bool(false)
isBolt() bool(false)
isTeaShark() bool(false)
isBlazer() bool(false)
isSafari() bool(false)
isMidori() bool(false)
isTizen() bool(false)
isUCBrowser() bool(false)
isGenericBrowser() bool(false)
Experimental version() method
version(Chrome) float(23.0127197)
version(Safari) int(0)
version(Webkit) float(537.11)
version(Gecko) int(0)
Other tests
isiphone() bool(false)
isIphone() bool(false)
istablet() bool(false)
isIOS() bool(false)
isWhateverYouWant() bool(false)

isFlashLiteOS() gives value "NULL"

User agent is detected as "zilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17"

Does not detect Microsoft Surface as a tablet

Default User Agent:
Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; ARM; Trident/6.0; Touch)

User Agent when in desktop mode:
Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; ARM; Trident/6.0; Touch)

Notice, they are both the same. If you do detect the Microsoft Surface as a tablet, when the user switches their tablet to desktop mode, it will still be recognized as a tablet, when it probably should respect the users decision and recognize it as a desktop.

Nokia C2-03

I'm seeing the Nokia C2-03 pop up in visits to our non-mobile (desktop and tablet) sites, especially in India. I couldn't find it in the mobile_detect file.

Add Mobile-detect to packagist

Hello,

first congrats on your work !

I wanted to know if you could add mobile-detect to packagist, so your users can stay automatically up to date ?
It should not be a big deal of work, but I cannot offer a PR as I have no way to test it (I don't think you can delete a package once added to packagist.org or disown it to another personn). User Suncat2000 forked your repo a few months ago and created a package with this outdated version, which should be a base for creating your official package : https://github.com/suncat2000/php-mobile-detect/blob/master/composer.json

I have created a first draft in a gist : https://gist.github.com/4111592

Thanks

Integrate with Wordpress

I am having a bit of trouble getting this to work on my Wordperss theme.

In my functions.php file I have

include("includes/Mobile_Detect.php"); $detect = new Mobile_Detect;

and then in my header.php file I have:

`if ($detect->isMobile() || $detect->isTablet()) {
    echo '<h1>MOBILE</h1>';
} else {
    echo '<h1>DESKTOP</h1>';
}`

However I get the following error:

Fatal error: Call to a member function isMobile() on a non-object.

Any suggestions?

All BrowserStack Android tablets are detected as phone

  • Amazon Kindle Fire 2
  • Amazon Kindle Fire HD 8.9
  • Google Nexus 7
  • Samsung Galaxy Note 10.1
  • Samsung Galaxy Tab 2 10.1

I've verified with real Galaxy Note 10.1 and it's detected as phone as well. UA string is

Mozilla/5.0 (Linux;U Android 4.04; nl-nl; GT-N8010 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30

Windows phone IE website preference

Hi,

I'm using mobile detect in my project and i test it in my android phone browers like Firefox and chrome. Also "request desktop site" works fine. But there' s problem with my windows phone Nokia Lumia 800 (OS 7.5) where mobile detection works well, but if i choose witch website preference (like android "request desktop site") mode (desktop or mobile), it always shows mobile mode.

Can anyone please help me to fix it or is there already available solutions.

Google Chrome taking on Mobile default

I have an app I am working on but when I test it with Goog's Chrome (newest) that browser takes on the styles from the mobile style-sheet I have defined... it is not screen size as my browser is displayed 1280x1024 and I have used CCleaner to remove cookies and temp files.
Every other browser works fine.
I have reset style-sheets in a manner that I thought may have de-configured any classes during the time frame I was checking the app in Google Chrome and no results.

this may not be so crazy of an event if I load some jquery to allocate cross-browser functions but, my biggest concernβ€”not to change subjectsβ€”is:

the PORTRAIT ORIENTATION is very hard for me to style even when I use <xmp>@media</xmp> only screen and portrait or any [correct] syntax usage thereof. I can not get the height of my home page table elements to expand to a larger size so each cell is tall and uniform (square) as it would look on a PC. http://vizuit.com <-mostly just the home page table I can not get to conform in portrait/mobilt styles.

Have tried specific <xmp>@media</xmp> for my LG Optimus L9 at 960x540 (using <xmp>@media only screen and (max-device-width: 540px) and (orientation: portrait) { }</xmp> ) to no avail.

Android 4.0.4 defaut browser detected as mobile when "Request Desktop Site" is on.

I also tested other browsers that have this option (Firefox, Chrome and Opera) and they all work as expected.

The user agent when desktop mode is enabled is:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.34 Safari/5.34.24

The phone itself is a Sony xperia active with the standard software.

I was using version 2.1 RC2 of Mobile_Detect.

MACBOOK PRO 13

The MACBOOK PRO 13 system 10.8.2 and safari, is not detected as DESKTOP computer.

Iphone5 iOS6/6.1

Im not sure if you enabled detection for Iphone5 with iOS6/6.1 but it doesnt work for me.
Can anyone confirm this ?

Library version and third part code

Hi all,

I have notice that in commit f0b61ab you have moved the version number of the library from the doc comments to the scriptVersion member.

Why removing the doc comment since the commit message says "Added script version".
Is it an oversight or there a real meaning behind that change.

I'm asking it cause there a Drupal module that use the library and check the version number with a regular expression (it doesn't work now cause that change, http://drupal.org/node/1924550).

Thanks guys,

China LY-F1 android tablet not detected as tablet.

AndroidOS: 4.1.1
China tablet name: LY-F1
Firmware: Custom

Information passed to web server by your browser
Host: show-ip.net
Connection: keep-alive
Referer: http://www.google.ru/url?sa=t&rct=j&q=show%20user%20agent&source=web&cd=1&sqi=2&ved=0CDIQFjAA&url=http%3A%2F%2Fshow-ip.net%2Fbrowserinfo%2F&ei=_tE1UdK2B4KN4ATS44BY&usg=AFQjCNHf2kHJ_gwmwmw5HYw2px4UEbH5vQ&sig2=1JI-Yv3auaCeqkMIVe6IsA&bvm=bv.43148975,d.bGE&cad=rjt
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
X-Requested-With: mobi.mgeek.TunnyBrowser
User-Agent: Mozilla/5.0 (Linux; U; Android 4.1.1; ru-ru; GT-I9100 Build/JRO03C) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30
Accept-Encoding: gzip,deflate
Accept-Language: ru-RU, en-US
Accept-Charset: utf-8, iso-8859-1, utf-16, *;q=0.7

Please, see http://www.handsetdetection.com/properties/vendormodel - big list of useragents for handsets devices

Error on Mobile_Detect.php line 22

I'm getting an error:
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in Mobile_Detect.php on line 22
It shows only on my ixwebhosting server. I tested it on hostgator and there is no problem at all.
Any idea?

Dell Tablets and Phones

Mozilla/5.0 (Linux; U; Android 1.6; en-gb; Dell Streak Build/Donut AppleWebKit/528.5+ (KHTML, like Gecko) Version/3.1.2 Mobile Safari/ 525.20.1

Is a dell tablet and it's not recognized. Should research all DELL phones and tablets.

Usage of master branch

The master branch is ready for use in production?

The background of my question:

The Drupal module Mobile Switch uses Mobile Detect. A feature of Mobile Switch is the automatic version check for Mobile Detect. This version check uses the RAW URL of the master branch.
The master branch is downloaded when detected a new "Mobile Detect 'version.

failure to recognize Nexus 10

This is a computer. Your UA is Mozilla/5.0 (X11; linux x86_64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.34 Safari/534.24

Failed to recognize Nexus 10 tablet when loading url from Pocket app

No isPhone() method??

This class seems doesn't seem to have an easy way to detect phones (we have to 1st detect mobile then do a ! isTablet() which is kind of crappy.

Please provide a way for people to detect if something is a phone!

Windows Phone 8 false detection

I've a brand new Nokia Lumia 620, running WP8.

The UA string is :

    Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM;Touch; NOKIA; Lumia 620)

WindowsPhoneOS is defined by

    'WindowsPhoneOS'   =>  'Windows Phone OS|XBLWP7|ZuneWP7'

So it won't match this UA.

I would submit a patch, but don't know enough about the others Windows Phones/Mobile UA.

Quickfix would be :

    'WindowsPhoneOS'   => 'Windows Phone OS|Windows Phone [7-9.]+|XBLWP7|ZuneWP7' 

(I guess.)

Chrome on iPad bug

UA: Mozilla/5.0 (iPad; CPU OS 5_1_1 like Mac OS X; en-us) AppleWebKit/534.46 (KHTML, like Gecko) CriOS/23.0.1271.91 Mobile/9B206 Safari/7534.48.3

$isMobile = $detect->isMobile();

on safari for ipad returnes true
on chrome for ipad returnes false

nevermind!

NetFront on Nexus 7 Tablet wrong user-agent

    [HTTP_HOST] => ghita.org
    [HTTP_CONNECTION] => close
    [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    [HTTP_X_REQUESTED_WITH] => com.access_company.android.nflifebrowser.lite
    [HTTP_USER_AGENT] => Mozilla/5.0 (Linux; U; Android; en_us; Nexus 7 Build/) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 NetFrontLifeBrowser/2.3 Mobile (Dragonfruit)
    [HTTP_ACCEPT_ENCODING] => gzip,deflate
    [HTTP_ACCEPT_LANGUAGE] => en-US
    [HTTP_ACCEPT_CHARSET] => utf-8, iso-8859-1, utf-16, *;q=0.7
    [REQUEST_TIME] => 19-09-2012 17:38

NetFront + Nexus 7 Tablet => isNexus() = true; isNexusTablet() = false;

Samsung Galaxy Note (tablet)

Mozilla/5.0 (Linux; U; Android 4.0.4; en-ca; GT-N8010 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30

Not recognized as a tablet. Should update the tablets from Samsung with newest releases.

Samsung Galaxy phone not detected as mobile phone on Browserstack

Hi, the Samsung Galaxy I, II, and III phones aren't registering as mobile phones on Browserstack. Please correct me if I'm wrong and you're seeing something different. We are detecting mobile phones using Varnish, but we're using the same regex for mobile phones contained in this library. We're using the latest 2.5.3 version.

New Methods for obtaining information about the device

I'd like to suggest that these methods be added to the project

public function getUseragent() {
    return $this->userAgent;
}

Sometimes it's useful to be able to pull back exactly which useragent was matched, this is because of the proxy / spoofing that goes on. At the moment the userAgent property is protected so it needs a getter.

I'm working on a project where I need to quickly determine information about a device. I've worked on much bigger projects like this in the past collating information from either the WURFL or Device Atlas (depending on what the organisation was using) to then group handsets together. So a similar aim to the roadmap for this project. This new project has no existing device detection library, have no money to pay for Device Atlas and the new wURFL license means it's not feasible for them to use as a source, hence why I have been looking at Mobile-Detect.

In order to achieve my aims, I've written a couple of quick methods to help me pull back information, on the whole they wrap a central protected method which does the guts of the work

/**
 * getPropetyDetail()
 * Returns the value of the property of the identified device
 * @param string $method
 * @return string
 * @throws \UnexpectedValueException
 */
protected function getPropetyDetail( $method) {
    if ( ! method_exists($this, $method)) {
        throw new UnexpectedValueException( 'Method name ' . $method .' was not expected' );
    }
    foreach($this->$method() as $name => $regex) {
        $check = $this->{'is'.$name}();
        if ($check) return $name;
    }
    return '';
}

/**
 * getBrand()
 * Returns the name of the "brand"
 * @return string
 * @throws \UnexpectedValueException
 */
public function getBrand() {
    return $this->getPropetyDetail('getRules');
}

/**
 * getOs()
 * Returns the name of the "OS"
 * @return string
 * @throws \UnexpectedValueException
 */
public function getOs() {
    return $this->getPropetyDetail('getOperatingSystems');
}

/**
 * getTabletMake()
 * Returns the make of the tablet
 * @return string
 * @throws \UnexpectedValueException
 */
public function getTabletMake() {
    return $this->getPropetyDetail('getTabletDevices');
}

/**
 * getPhoneMake()
 * Returns the make of the phone
 * @return string
 * @throws \UnexpectedValueException
 */
public function getPhoneMake() {
    return $this->getPropetyDetail('getPhoneDevices');
}

I've also created one to return version information

/**
 * getVersion
 * Returns a stdClass with properties of each version which has been detected
 * @return stdClass
*/
public function getVersion() {
    $return = new stdClass();
    foreach($this->getProperties() as $name => $regex) {
        $check = $this->version($name);
        if ($check) $return->$name = $check;
    }
    return $return;
}

Finally, I put together another method to wrap these and return everything in one object

public function getDetails() {

    $return = new stdClass();
    $return->type = 'unknown';
    $return->useragent = $this->getUseragent();

    // Work out the device details
    $return->isBrand = $this->getBrand();
    $return->isMobile = $this->isMobile();
    $return->isTablet = $this->isTablet();

    // Get the names
    $return->mobile = $this->getPhoneMake();
    $return->tablet = $this->gettabletMake();

    // General
    $return->os = $this->getOs();

    // Work out the version of the OS. Due to the regex used, tweaks need to be made
    $return->versions = $this->getVersion();
    if (isset($return->versions->{$return->isBrand}) ) {
        // Works for iPhone and Blackberry
        $return->version = $return->versions->{$return->isBrand};
    } elseif ( 'WindowsPhoneOS' == $return->os && isset($return->versions->{'Windows Phone OS'}) ) {
        // Windows
        $return->version = $return->versions->{'Windows Phone OS'};
    } elseif ('AndroidOS' == $return->os && isset($return->versions->Android)) {
        // Android
        $return->version = $return->versions->Android;
    } elseif ('SymbianOS' == $return->os && isset($return->versions->Symbian)) {
        // Symbian
        $return->version = $return->versions->Symbian;
    } elseif (isset($return->versions->Mobile) ) {
        // A fallback not really good enough
        $return->version = $return->versions->Mobile;
    } else {
        $return->version = 0;
    }

    // Determine type of device
    if ($return->isTablet) {
        $return->type = 'tablet';
    } elseif ($return->isMobile) {
        $return->type = 'mobile';
    } elseif ($return->isBrand) {
        $return->type = 'isBrand';
    }

    return $return;
}

This results in the following output

stdClass::__set_state(array(
'type' => 'mobile',
'useragent' => 'Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; SAMSUNG; SGH-i677)',
'isBrand' => 'Samsung',
'isMobile' => true,
'isTablet' => false,
'mobile' => 'Samsung',
'tablet' => '',
'os' => 'WindowsPhoneOS',
'versions' =>
stdClass::__set_state(array(
'Mobile' => 9,
'IEMobile' => 9,
'MSIE' => 9,
'Trident' => 5,
'Windows Phone OS' => 7.5,
)),
'version' => 7.5,
))

Return Type function.

You could add this function to return the type of device (mobile, tablet, other) and the device name.

public function type() {
$response = array(
'type' => 'other',
'device' => 'na',
);
if($this->isMobile()) {
$response['type'] = 'mobile';
foreach($this->phoneDevices as $key=>$val) {
if($this->is($key)) {
$response['device'] = $key;
}
}
}
if($this->isTablet($this->userAgent)) {
$response['type'] = 'tablet';
foreach($this->tabletDevices as $key=>$val) {
if($this->is($key)) {
$response['device'] = $key;
}
}
}
return $response;
}

Tapatalk (not detected as mobile)

Hello,

First of all thank you for your detection class and your well documented website.

I've integrated your class to XenForo via an addon (Source: http://xenforo.com/community/resources/browser-detection-mobile-msie.1098/) which is being used by others addons to set mobile options.

Some members told me that if a post (XenForo is a forum) was made from the mobile application Tapatalk (Source: www.tapatalk.com), which seems to use its own name as useragent,it is not detected as a mobile device.

Would you consider to add this to your class? If needed I can do it myself and share the code with you. It's up to you.

Have a nice day

obtaining max device width

Hello,

First thanks for publishing this code. It's very useful.

I wonder when i do:

// 3. Check for any mobile device, excluding tablets.

if ($detect->isMobile() && !$detect->isTablet()) {
// Your code here.
}

Do i know something about the max device width (landscape)? I want to use your class to serve images with the max device width instead of scale them by css.

When i look to http://twitter.github.com/bootstrap/scaffolding.html "Supported devices", i found:
Landscape phones and down <= 480px
so it will be nice when the above if statement also would be true for max device width = 480 px.

Otherwise it would maybe be useful to have something like:
$detect->isNormalPhone() // max width 480
$detect->isLargePhone() // max width 767

or $detect->GetMaxWidth(); or $detect->isMaxWidth480(); etc.

Thanks and best regards,

Bass

wrong detection when PHONE & PHONE_UA headers are present

    [HTTP_USER_AGENT] => Opera/9.80 (Android; Opera Mini/7.0.29952/28.2504; U; en) Presto/2.8.119 Version/11.10
    [HTTP_HOST] => ghita.org
    [HTTP_ACCEPT] => text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/webp, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1
    [HTTP_ACCEPT_LANGUAGE] => en
    [HTTP_ACCEPT_ENCODING] => gzip, deflate
    [HTTP_CONNECTION] => close
    [HTTP_X_OPERAMINI_FEATURES] => advanced, file_system, camera, touch, folding, viewport, routing
    [HTTP_X_OPERAMINI_PHONE] => Android #
    [HTTP_X_OPERAMINI_PHONE_UA] => Mozilla/5.0 (Linux; U; Android 4.1.1; en-us; Nexus 7 Build/JRO03D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30
    [REQUEST_TIME] => 19-09-2012 17:32

JSON metadata and Ruby version

I forked the repo this evening and have created a basic ruby library for running the same regex as your PHP library.

To do this I had to convert the PHP regex arrays into Ruby, and to make it maintainable I extracted the regex into a JSON file so I could read them into Ruby.

I don't know if this is a direction you've considered, but I thought it was the easiest way to be able to keep it in sync with your current library.

I also created a script which will run through a CSV file, compare the useragents mentioned within and add detection results to the file... this was the use-case I wanted to use the library for, so I thought I'd publish it also.

Porting library to Node.js

Hello!

Unfortunately i didn't find a good library to detect browsers for nodejs. Also i can't find any license info on your github page. Could I use your code and port it to nodejs and public library with note that is ported from your project?

PS: Great job! :)

Desktop detection and get_browser

Since browscap doesn't have the ability to distinguish between a phone and a tablet, it would be very nice to replace browscap with mobile-detect. Do you have any plans to add desktop detection, OS version, etc. to mobile-detect?

Specifically, my need would be for the following array:

Array
(
[platform] => WinXP
[browser] => Firefox
[version] => 0.9
[majorver] => 0
[minorver] => 9
);

HTML implementation

Hi there,

thanks for the script. Looks really promising, although I can't get it to work.

Basically I want the most common thing; redirect al mobile devices to a specific URL.
I'm not experienced with PHP, my website is in Flash (loaded from a HTML) and that's why I want to redirect mobile viewers.

So, I've uploaded Mobile_Detect.php to my root. My indextest.html (http://www.merkelbach.nl/indextest.html) loads the flash file. In the HTML I've added the php script. That doesn't work. Then I've tried to rename it to .php (http://www.merkelbach.nl/indextest.php). That gives me a blank page.

Been looking for solutions for a few hours now but I can't get it to work. Please help.

Thanks.

Martin

Please add these two functions

Hello,

I'm using this class to get vague names of user devices. Could you add these two functions to the class:

public function getPhoneDevices(){

return $this->phoneDevices;

}

public function getTabletDevices(){

return $this->tabletDevices;

}

This would make upgrading easier :)

isTablet doesn't seem to be working correctly.

The isTablet() and isiPad() on a mobile device is returning true.

Mozilla/5.0 (iPad; CPU OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3

Chrome Detection

Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11

The plugin doesn't detect this is chrome.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.