Skip to content

Instantly share code, notes, and snippets.

@jeonghwan-kim
Created October 14, 2013 01:48
Show Gist options
  • Select an option

  • Save jeonghwan-kim/6969552 to your computer and use it in GitHub Desktop.

Select an option

Save jeonghwan-kim/6969552 to your computer and use it in GitHub Desktop.

Revisions

  1. jeonghwan-kim created this gist Oct 14, 2013.
    14 changes: 14 additions & 0 deletions detect-mobile-devices.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    <?php
    //Detect devices
    $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");

    if ( $Android )
    echo 'Android';
    else if ( $iPod || $iPhone || $iPad )
    echo 'iPhone';
    else
    echo 'Desktop';
    ?>