Determine user device and display different content with php

First save the page as .php and use the following code to check the device user is using

<?php
$iphone = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$android = strpos($_SERVER['HTTP_USER_AGENT'],"Android");
$ipad = strpos($_SERVER['HTTP_USER_AGENT'],"iPad");
  ?>

Then use the information found to determine the content to display accordingly

  <?php if($iphone !== FALSE || $ipad !== FALSE) { ?>

   //iOS contents goes here

  <?php }  else if ($android !== FALSE ) { ?>

    //Android content goes here

  <?php } else {?>

    //Web based and others content goes here


  <?php } ?>