// Originally from http://mobile.tutsplus.com/tutorials/html5/mobile-browser-detection/
// I tweaked it to support mobile stylesheets.
function mobileCSS() {
$agent = $_SERVER['HTTP_USER_AGENT'];
if(preg_match('/iPhone|Android|Blackberry/i', $agent)){
echo "mobile.css";
}
else {
echo "main.css";
}
}
<link rel="stylesheet" type="text/css" href="css/<?php mobileCSS(); ?>" media="screen" charset="utf-8" />