Detect most mobile HTTP clients
Copy this code and paste it in your HTML
/**
* Detects most mobile agents.
*
* @return bool
* @see http://en.wikipedia.org/wiki/List_of_user_agents_for_mobile_phones
*/
function isMobile()
{
$userAgent = $_SERVER["HTTP_USER_AGENT"];
$yes = strpos($userAgent, "Android") !== false; $yes = $yes || strpos($userAgent, "iPhone") !== false; $yes = $yes || strpos($userAgent, "Palm") !== false; $yes = $yes || strpos($userAgent, "Symbian") !== false; $yes = $yes || strpos($userAgent, "Mobile") !== false; $yes = $yes || strpos($userAgent, "MIDP") !== false; $yes = $yes || strpos($userAgent, "CLDC") !== false; return $yes;
}
Report this snippet
Comments
Subscribe to comments