Mobile
in package
Detect browser type (mobile or desktop)
Table of Contents
Properties
- $browsers : array<string|int, mixed>
- Browsers
- $headers : array<string|int, mixed>
- Request headers
- $mobileHeaders : array<string|int, mixed>
- Mobile headers
- $os : array<string|int, mixed>
- Os
- $rules : array<string|int, mixed>
- Rules
- $userAgent : string|null
- User agent
- $userAgentHeaders : array<string|int, mixed>
- User agent headers
- $utilities : array<string|int, mixed>
- Utilities
- $isMobile : bool|null
- Save mobile mobile device check
Methods
- __construct() : mixed
- Constructor
- checkHeadersForMobile() : bool
- Check for mobile headers
- initHeaders() : void
- Init headers
- initUserAgent() : void
- Init user agent
- isMobile() : bool
- Return true if page is open from mobile browser
- mobile() : bool
- Return true if page is open from mobile browser
- match() : bool
- Match helper
- matchUserAgent() : bool
- Check user agent
Properties
$browsers
Browsers
protected
array<string|int, mixed>
$browsers
= ['Chrome' => '\\bCrMo\\b|CriOS|Android.*Chrome/[.0-9]* (Mobile)?', 'Dolfin' => '\\bDolfin\\b', 'Opera' => 'Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR/[0-9.]+|Coast/[0-9.]+', 'Skyfire' => 'Skyfire', 'Edge' => 'Mobile Safari/[.0-9]* Edge', 'IE' => 'IEMobile|MSIEMobile', 'Firefox' => 'fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile|FxiOS', 'Bolt' => 'bolt', 'TeaShark' => 'teashark', 'Blazer' => 'Blazer', 'Safari' => 'Version.*Mobile.*Safari|Safari.*Mobile|MobileSafari', 'UCBrowser' => 'UC.*Browser|UCWEB', 'baiduboxapp' => 'baiduboxapp', 'baidubrowser' => 'baidubrowser', 'DiigoBrowser' => 'DiigoBrowser', 'Puffin' => 'Puffin', 'Mercury' => '\\bMercury\\b', 'ObigoBrowser' => 'Obigo', 'NetFront' => 'NF-Browser', 'GenericBrowser' => 'NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger', 'PaleMoon' => 'Android.*PaleMoon|Mobile.*PaleMoon']
$headers
Request headers
protected
array<string|int, mixed>
$headers
$mobileHeaders
Mobile headers
protected
array<string|int, mixed>
$mobileHeaders
= ['HTTP_ACCEPT' => ['matches' => ['application/x-obml2d', 'application/vnd.rim.html', 'text/vnd.wap.wml', 'application/vnd.wap.xhtml+xml']], 'HTTP_X_WAP_PROFILE' => null, 'HTTP_X_WAP_CLIENTID' => null, 'HTTP_WAP_CONNECTION' => null, 'HTTP_PROFILE' => null, 'HTTP_X_OPERAMINI_PHONE_UA' => null, 'HTTP_X_NOKIA_GATEWAY_ID' => null, 'HTTP_X_ORANGE_ID' => null, 'HTTP_X_VODAFONE_3GPDPCONTEXT' => null, 'HTTP_X_HUAWEI_USERID' => null, 'HTTP_UA_OS' => null, 'HTTP_X_MOBILE_GATEWAY' => null, 'HTTP_X_ATT_DEVICEID' => null, 'HTTP_UA_CPU' => ['matches' => ['ARM']]]
$os
Os
protected
array<string|int, mixed>
$os
= ['AndroidOS' => 'Android', 'BlackBerryOS' => 'blackberry|\\bBB10\\b|rim tablet os', 'PalmOS' => 'PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino', 'SymbianOS' => 'Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\\bS60\\b', 'WindowsMobileOS' => 'Windows CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Window Mobile|Windows Phone [0-9.]+|WCE;', 'WindowsPhoneOS' => 'Windows Phone 10.0|Windows Phone 8.1|Windows Phone 8.0|Windows Phone OS|XBLWP7|ZuneWP7|Windows NT 6.[23]; ARM;', 'iOS' => '\\biPhone.*Mobile|\\biPod|\\biPad|AppleCoreMedia', 'MeeGoOS' => 'MeeGo', 'MaemoOS' => 'Maemo', 'JavaOS' => 'J2ME/|\\bMIDP\\b|\\bCLDC\\b', 'webOS' => 'webOS|hpwOS', 'badaOS' => '\\bBada\\b', 'BREWOS' => 'BREW']
$rules
Rules
protected
array<string|int, mixed>
$rules
$userAgent
User agent
protected
string|null
$userAgent
$userAgentHeaders
User agent headers
protected
array<string|int, mixed>
$userAgentHeaders
= ['HTTP_USER_AGENT', 'HTTP_X_OPERAMINI_PHONE_UA', 'HTTP_X_DEVICE_USER_AGENT', 'HTTP_X_ORIGINAL_USER_AGENT', 'HTTP_X_SKYFIRE_PHONE', 'HTTP_X_BOLT_PHONE_UA', 'HTTP_DEVICE_STOCK_UA', 'HTTP_X_UCBROWSER_DEVICE_UA']
$utilities
Utilities
protected
array<string|int, mixed>
$utilities
= ['Bot' => 'Googlebot|facebookexternalhit|AdsBot-Google|Google Keyword Suggestion|Facebot|YandexBot|YandexMobileBot|bingbot|ia_archiver|AhrefsBot|Ezooms|GSLFbot|WBSearchBot|Twitterbot|TweetmemeBot', 'MobileBot' => 'Googlebot-Mobile|AdsBot-Google-Mobile|YahooSeeker/M1A1-R2D2', 'DesktopMode' => 'WPDesktop', 'TV' => 'SonyDTV|HbbTV', 'WebKit' => '(webkit)[ /]([\\w.]+)', 'Console' => '\\b(Nintendo|Nintendo WiiU|Nintendo 3DS|PLAYSTATION|Xbox)\\b', 'Watch' => 'SM-V700']
$isMobile
Save mobile mobile device check
private
static bool|null
$isMobile
= null
Methods
__construct()
Constructor
public
__construct() : mixed
checkHeadersForMobile()
Check for mobile headers
public
checkHeadersForMobile() : bool
Return values
boolinitHeaders()
Init headers
public
initHeaders() : void
initUserAgent()
Init user agent
public
initUserAgent() : void
isMobile()
Return true if page is open from mobile browser
public
isMobile() : bool
Return values
boolmobile()
Return true if page is open from mobile browser
public
static mobile() : bool
Return values
boolmatch()
Match helper
protected
match(string $regex) : bool
Parameters
- $regex : string
Return values
boolmatchUserAgent()
Check user agent
protected
matchUserAgent() : bool