PHP でのスマホ判定


タブレットの普及や新しい OS の誕生など時代の流れにあわせないと・・・。

function isSmart(){
	$useragents = array(
					'iPhone',			// iPhone
					'iPod',				// iPod touch
					'Android.*Mobile',	// 1.5+ Android *** Only mobile
					'Windows.*Phone',	// Windows Phone
					'firefox.*Mobile',	// Firefox *** Only mobile
					'blackberry',		// Blackberry
					'incognito',		// Other iPhone browser
					'webmate'			// Other iPhone browser
	);
	$pattern = '/'.implode( '|', $useragents ).'/i';
	$bool = preg_match( $pattern, $_SERVER['HTTP_USER_AGENT'] ) ? TRUE : FALSE;
	return( $bool );
}

[mokurenCB]