You don't need a library to detect something like this...naim wrote:
- You can make an address for mobiles (ex. example.com/phpbb/m) and add a "desktop" link.
- For auto-detection, i found this library that might be helpful: http://code.google.com/p/php-mobile-detect/
That library is incompatible with PHP as it is released under the MIT license, anyway.
It is also 91 lines long, most of which are defining useless variables that wouldn't be used. The following code would do:
Code: Select all
$match = '/(android.*mobile|android(?!.*mobile)|blackberry|rim tablet os|iphone|ipod|ipad|avantgo|blazer|elaine|hiptop|palm|plucker|xiino|windows ce; (iemobile|ppc|smartphone)|windows phone os|kindle|mobile|mmp|midp|o2|pda|pocket|psp|symbian|smartphone|treo|up.browser|up.link|vodafone|wap|opera mini)/i'; $is_mobile = (bool) preg_match($match, $user->browser);