Return to Snippet

Revision: 39710
at January 20, 2011 02:16 by dropthenerd


Updated Code
function mobileCheck(){
	$mobile = isset($_GET['mobile']) ? true : false;
	$user_agent = $_SERVER['HTTP_USER_AGENT'];
	
	$devices = array('iPhone','iPod','iPad');
	
	foreach($devices as $device){
		if(strpos($user_agent,$device) || $mobile == true) return true;
	}
	return false;
}

Revision: 39709
at January 20, 2011 02:14 by dropthenerd


Initial Code
function mobileCheck(){
	$mobile = isset($_GET['mobile']) ? true : false;
	$user_agent = $_SERVER['HTTP_USER_AGENT'];

	$devices = array('iPhone','iPod','iPad');

	foreach($devices as $device){
		if(strpos($user_agent,$device) || $mobile == true) return true;
	}

       return false;
}

Initial URL
http://www.dropthenerd.com/how-to-easily-detect-mobile-devices/

Initial Description

                                

Initial Title
How to easily detect mobile devices

Initial Tags
mobile, user, iphone

Initial Language
PHP