For anyone who wants to use it..
This is a way to detect with php if a visitor to your web site is using a mobile device browser.. it works. If you have a mobile device that this doesn't detect, all you have to do to add it is to find a unique bit of identifying information in your device's user agent and stick it in the list of mobile devices in this code.
------------
<?php
/* detect mobile device*/
$ismobile = 0;
$container = $_SERVER['HTTP_USER_AGENT'];
// A list of mobile devices
$useragents = array (
'Blazer' ,
'Palm' ,
'Handspring' ,
'Nokia' ,
'Kyocera',
'Samsung' ,
'Motorola' ,
'Smartphone',
'Windows CE' ,
'Blackberry' ,
'WAP' ,
'SonyEricsson',
'PlayStation Portable',
'LG',
'MMP',
'OPWV',
'Symbian',
'EPOC',
);
foreach ( $useragents as $useragents ) {
if(strstr($container,$useragents)) {
$ismobile = 1;
}
}
if ( $ismobile == 1 ) {
echo "<p>mobile device</p>";
echo $_SERVER['HTTP_USER_AGENT'];
}
?>
This is a way to detect with php if a visitor to your web site is using a mobile device browser.. it works. If you have a mobile device that this doesn't detect, all you have to do to add it is to find a unique bit of identifying information in your device's user agent and stick it in the list of mobile devices in this code.
------------
<?php
/* detect mobile device*/
$ismobile = 0;
$container = $_SERVER['HTTP_USER_AGENT'];
// A list of mobile devices
$useragents = array (
'Blazer' ,
'Palm' ,
'Handspring' ,
'Nokia' ,
'Kyocera',
'Samsung' ,
'Motorola' ,
'Smartphone',
'Windows CE' ,
'Blackberry' ,
'WAP' ,
'SonyEricsson',
'PlayStation Portable',
'LG',
'MMP',
'OPWV',
'Symbian',
'EPOC',
);
foreach ( $useragents as $useragents ) {
if(strstr($container,$useragents)) {
$ismobile = 1;
}
}
if ( $ismobile == 1 ) {
echo "<p>mobile device</p>";
echo $_SERVER['HTTP_USER_AGENT'];
}
?>