PHP Ways to Make Web Site Mobile Access More Friendly

  • 2021-11-24 01:07:47
  • OfStack

PHP is all processed on the server, so when the code reaches the user, it is just HTML.

Basically, the user requests 1 page of your website from your server, and then your server runs all PHP and sends the result of PHP to the user.

Devices never actually see or have to use the actual PHP code. This gives Web sites completed using PHP an advantage over other languages processed on the client side, such as Flash.

Redirecting users to a mobile version of your website has become popular. This can be done with htaccess file or PHP. One way is to use strpos () to find the names of some devices.

Here's an example:

$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)

If you choose to redirect users to a mobile site, be sure to provide users with an easy way to access the entire site.

Another thing to keep in mind is that if someone enters your site from a search engine, they usually don't browse your home page, so they don't want to be redirected there. Instead, redirect them from SERP (search engine results page) to the mobile version of the article.

Interestingly, this CSS switcher script may have been written in PHP. This allows users to place different CSS templates through the drop-down menu. This will allow you to provide the same content in different mobile-friendly versions, perhaps one for your phone and one for your tablet. In this way, users can choose to change one of the templates, but they can also choose to keep the full version of the site if they want.

One last thing to consider: While PHP is ideal for mobile sites, people often combine PHP with other languages so that their sit can do anything they want. Be careful when adding new features, lest they make your site unusable by members of the mobile community.

Related articles: