Wednesday 1 April 2015

PHP: Detect what browser your website is being accessed from using php

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


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


?>

0 comments:

Post a Comment