Welcome, guest | Sign In | My Account | Store | Cart

This is a short hack on how to figure out what OS you site is being accessed from. This is useful if you want to redirect to different versions of your site through php.

PHP, 9 lines
1
2
3
4
5
6
7
8
9
<?php

    $iPod    = stripos($_SERVER['HTTP_USER_AGENT'],"iPod");
    $iPhone  = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone");
    $iPad    = stripos($_SERVER['HTTP_USER_AGENT'],"iPad");
    $Android = stripos($_SERVER['HTTP_USER_AGENT'],"Android");
    $webOS   = stripos($_SERVER['HTTP_USER_AGENT'],"webOS");

?> 

For more cool codes checkout my blog Captain DeadBones Chronicles

Created by Captain DeadBones on Wed, 19 Jun 2013 (MIT)
PHP recipes (51)
Captain DeadBones's recipes (47)

Required Modules

  • (none specified)

Other Information and Tasks