Ejemplos:
<?php
$iphone = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone"); $android = strpos($_SERVER['HTTP_USER_AGENT'],"Android"); $palmpre = strpos($_SERVER['HTTP_USER_AGENT'],"webOS"); $berry = strpos($_SERVER['HTTP_USER_AGENT'],"BlackBerry"); $ipod = strpos($_SERVER['HTTP_USER_AGENT'],"iPod");
if ($iphone || $android || $palmpre || $ipod || $berry == true)
{
header('Location: http://mobile.site.com/'); //OR
echo "<script>window.location='http://mobile.site.com'</script>";
}
?>
$phones = array('iPhone', 'Android', 'BlackBerry');
redirect
}
$mobile = 'http://mobile.mysite.com/';
if ((strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone')) && empty($_COOKIE["mobilesitez"]) && $_SERVER['REQUEST_URI']=="/") { header("Location: " . $mobile); }
Code added to mobile page:
function set_cookie () {
document.cookie = 'mobilesitez=mobilesitez; domain=.mysite.com;';
window.location = 'http://www.mysite.com/'
}
<?php
if(strstr($_SERVER['HTTP_USER_AGENT'],'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'],'iPod')) {
header('Location: http://yoursite.com/iphone'); }
?>
if( preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|webos|galaxy|phone|pocket|psp|treo|android|mobile|240x320|400X240|nitro|nokia|portalmmm|proxinet|blackberry|palm||series40|series60|s60|sonyericsson|e10i|samsung|nexus|htc|desire|ipod|itunes|vodafone|wap-|wapi|wapa|wapp|series40|series60|s60|sonyericsson)/i', $user_agent) ){ //do something here for all mobile phones
}
$mobile_agents = '!(tablet|pad|mobile|phone|symbian|android|ipod|ios|blackberry|webos)!i';
if(preg_match($mobile_agents, $_SERVER['HTTP_USER_AGENT'])) {
// Mobile!
}
$mobile = false;
if(isset($_SERVER['HTTP_USER_AGENT'])) {
$mobile_agents = '!(tablet|pad|mobile|phone|symbian|android|ipod|ios|blackberry|webos)!i';
if(preg_match($mobile_agents, $_SERVER['HTTP_USER_AGENT'])) {
$mobile = true;
}
}