Skip to content

Instantly share code, notes, and snippets.

@mono96
Created January 31, 2016 06:07
Show Gist options
  • Save mono96/61305c5cb8fabf09df2a to your computer and use it in GitHub Desktop.
Save mono96/61305c5cb8fabf09df2a to your computer and use it in GitHub Desktop.
//スマホ表示分岐
function is_mobile(){
$useragents = array(
'iPhone', // iPhone
'iPod', // iPod touch
'Android.*Mobile', // 1.5+ Android *** Only mobile
'Windows.*Phone', // *** Windows Phone
'dream', // Pre 1.5 Android
'CUPCAKE', // 1.5+ Android
'blackberry9500', // Storm
'blackberry9530', // Storm
'blackberry9520', // Storm v2
'blackberry9550', // Storm v2
'blackberry9800', // Torch
'webOS', // Palm Pre Experimental
'incognito', // Other iPhone browser
'webmate' // Other iPhone browser
);
$pattern = '/'.implode('|', $useragents).'/i';
return preg_match($pattern, $_SERVER['HTTP_USER_AGENT']);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment