Skip to content

Instantly share code, notes, and snippets.

@gavinblair
Created June 10, 2010 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gavinblair/433213 to your computer and use it in GitHub Desktop.
Save gavinblair/433213 to your computer and use it in GitHub Desktop.
Load a mobile theme if the user is using a smartphone
<?php
if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), "iphone") !== FALSE
|| strpos(strtolower($_SERVER['HTTP_USER_AGENT']), "ipod") !== FALSE
|| strpos(strtolower($_SERVER['HTTP_USER_AGENT']), "android") !== FALSE
|| strpos(strtolower($_SERVER['HTTP_USER_AGENT']), "blackberry") !== FALSE ) {
include 'mobile.php';
} else {
?><!DOCTYPE ...
@gavinblair
Copy link
Author

Fork me if you have a better way to do this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment