Technology Programming

Websites in a mobile world

In today's world it is important to make your website accessible to all of your users. Although many people still access your website though their computer, a huge amount of people are also accessing your website from their phones and tablets. When you are programming your website it is important to keep these types of media in mind so that your site will work on these devices.

One good thing to know is that PHP pages work on all of these devices!

The reason is that PHP is all processed on the server, so by the time the code gets to the user, it is just HTML. So basically, the user requests a page of your website from your server, your server then runs all the PHP and sends the user the results of the PHP. The device never actually sees or has to do anything with the actual PHP code. This gives websites done in PHP an advantage over other languages that process on the user side, such as Flash.

It has become popular to redirect users to mobile versions of your website. This is something that you can do with the htaccess file but you can also do with PHP. One way to do this is by using strpos() to look for the name of certain devices. Here is an example:

 

<?php$android = strpos($_SERVER['HTTP_USER_AGENT'],"Android");$bberry = strpos($_SERVER['HTTP_USER_AGENT'],"BlackBerry");$iphone = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");$ipod = strpos($_SERVER['HTTP_USER_AGENT'],"iPod");$webos = strpos($_SERVER['HTTP_USER_AGENT'],"webOS");if ($android || $bberry || $iphone || $ipod || $webos== true) { header('Location: http://www.yoursite.com/mobile');}?>

You have to be careful when you do this. I absolutely hate it when a website redirects my iPad to a mobile site. Even on my phone I often prefer the full site to the mobile version. It might be more useful to your users if you simply include a link to the mobile version of your website.

If you chose to redirect your users to a mobile site, make sure you give the user an escape. Don't force them to use the mobile version, at least give them a way to access your actual site.

Another thing to keep in mind is that if someone reaches your site from a search engine they often aren't going through your home page so they don't want to be redirected there. If I find a nice article on knitting elephant sweaters, even if I am redirected to a mobile site I want to read my elephant sweater article. If you put me on your home page, I then have to re-find your article which sometimes can be a big pain. Instead redirect them to the mobile version of the elephant sweater knitting article.

Something of interest may be this CSS switcher script written in PHP. This allows the user to put on a different CSS template via a drop down menu. This would allow you to offer the same content in different mobile friendly versions, perhaps one for phones and another for tablets. This way the user would have the option to change to one of these templates, but would also have the option to keep the full version of the site if they prefer.

One final consideration: Although PHP is good to use for websites that will be accessed by mobile users, people often combine PHP with other languages to make their sit do everything they want. Be careful when adding features that the new features won't make your site unusable by members of the mobile community! Happy programing!

Related posts "Technology : Programming"

Differences Between Byte Array Vs. String

Programming

Web Design Company UK/

Programming

Develop A Quality Plan With These Self Help Tips

Programming

TMediaPlayer: What track am I on?

Programming

How You Can Prove Your Expertise

Programming

Furniture Advice And Tips And Also Hardwearing. Property Searching Wonderful

Programming

Web Design Fort Lauderdale Business

Programming

Hire Web Designer and Diminish Development Expenditure

Programming

Web Masters.

Programming

Leave a Comment