This information is already in $_SERVER superglobal. All you gotta do is to find occurrence of Iphone/Ipdad etc
within $_SERVER['HTTP_USER_AGENT']
Just define some function that will do it for you, then make a redirect to particular page, like this (This is procedural approach):
<?php
$mobile = array('Iphone', 'Androind'); //etc add more
//We won't use global keyword
//We would pass an array as arg instead
function isMobile(array $mobile){
foreach($mobile as $agent){
if ( strpos($_SERVER['HTTP_USER_AGENT'], $agent) ){
//mobile detected
//or return its name, do it the way you like
return true;
}
}
}
//Now simply check then do redirect, like this
if ( isMobile($mobile) ){
header('Location: /some-mobile-page.php')
} else {
header('Location: /regular-page.php');
}