Reputation: 230
I would like to create an icon for my website when user visits my website from mobile. I assume i will have to check the OS which request the url and on knowing from where the request came ie Apple, Android or Blackberry phones and executing script which will create icon if accepted by user..
Can this be done ? If yes, then how ?
Upvotes: 2
Views: 1950
Reputation: 1978
Check the code below this will work
<?php
$ismobile = 0;
$container = $_SERVER['HTTP_USER_AGENT'];
// Mobile Company And Os
$useragents = array ('Blazer','Palm','Handspring','Nokia','Kyocera','Samsung','Motorola','Smartphone','Windows CE','Blackberry','WAP','SonyEricsson','PlayStation Portable','LG','MMP','OPWV','Symbian','EPOC','android','Android');
foreach ( $useragents as $useragents )
{
if(strstr($container,$useragents))
{
$ismobile = 1;
$browser = $useragents;
}
}
if ( $ismobile == 1 )
{
echo "<p>Browsing Using ".$browser." device</p>";
}
?>
And The Out Put Will Be Like Below
Browsing Using Android device
Upvotes: 2