Forked from jeonghwan-kim/detect-mobile-devices.php
Created
January 17, 2025 04:12
-
-
Save nhantam/a12b9da4fa5c797edf80d377b9a23f1e to your computer and use it in GitHub Desktop.
Detect mobile devices such as iPhone, android phone.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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'; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment