/ Published in: PHP

Based upon http://csswizardry.com/2010/01/iphone-css-tips-for-building-iphone-websites/
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$user_agent = $_SERVER['HTTP_USER_AGENT']; $iphone = strpos($user_agent,"iPhone"); $ipod = strpos($user_agent,"iPod"); $ipad = strpos($user_agent,"iPad"); $blackberry = stristr($user_agent,"BlackBerry"); $android = strpos($user_agent,"Android"); if ($iphone || $ipod || $blackberry || $android) { $browser = 'mobile phone'; if($iphone) {$browser .= ' iphone';} if($ipod) {$browser .= ' ipod';} if($blackberry) {$browser .= ' blackberry';} if($android) {$browser .= ' android';} } else if($ipad) { $browser = 'mobile tablet'; $browser .= ' ipad'; } else { $browser = 'desktop'; } /* To use in CSS: <body class="<?php echo $browser ?>"> */
Comments
