Skip to content

Instantly share code, notes, and snippets.

@mattlundstrom
Created June 15, 2012 22:46
Show Gist options
  • Save mattlundstrom/2939082 to your computer and use it in GitHub Desktop.
Save mattlundstrom/2939082 to your computer and use it in GitHub Desktop.
PHP Mobile Sniffer
<?php
$browser = getenv(“HTTP_USER_AGENT”);
echo '<p>HTTP User Agent is: ' . $browser . '</p>';
if (eregi(‘iPhone’, $browser))
{
echo 'You are using an iPhone';
}
else if (eregi(‘Blackberry’, $browser))
{
echo 'You are using a Blackberry';
}
else if (eregi(‘Android’, $browser))
{
echo 'You are using an Android';
}
else
{
echo 'browser undetected';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment