Tuesday, August 20, 2013

Redirect Mobile Devices Using PHP

Hi everyone!

Today, I want to share this useful article with you. This article is going to be about redirecting mobile devices with PHP programming language. I am sure that you will need it.
If you have your own web site or something else, It means that you have members, users or followers on your site. Sure, we should remember that most of people uses mobile devices. Internet, social media, game or some applications etc, and we know that they visit your web site from their mobile devices. For that reason if we put this special feature on, we get more quality site of course.
As I said the title, I am doing this using PHP. So, let me show you:
//just define user's agents (iphone or android)
$iphoneDevice  =  strpos($_SERVER['HTTP_USER_AGENT'], "iPhone");
$androidDevice =  strpos($_SERVER['HTTP_USER_AGENT'], "Android");

if($iphoneDevice) {
    print "Your device is iphone!";
}

if($androidDevice) {
    print "Your device is android, you can download Fast Boy Game 
Application from Play Google
"; print " FAST BOY"; }

That's it. If the user use iphone, will see "Your device is iphone!" message on the screen, if use android device,
Your device is android, you can download Fast Boy Game 
Application from Play Google
FAST BOY (clickable)

If you want to put more features on your web site, for example blackberry, webos or ipod, you can use already.
$webOSDevice      = strpos($_SERVER['HTTP_USER_AGENT'], "webOS");
$BlackBerryDevice = strpos($_SERVER['HTTP_USER_AGENT'], "BlackBerry");
$ipodDevice       = strpos($_SERVER['HTTP_USER_AGENT'], "iPod");
The code given above shows us other devices and brands.
We will see you next article!

No comments:

Post a Comment

Thanks