Last active
December 11, 2015 06:39
-
-
Save shoyan/4561150 to your computer and use it in GitHub Desktop.
USER_AGENTを見て判断するサンプル
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 | |
$userAgent = $_SERVER['HTTP_USER_AGENT']; | |
$isMobile = false; | |
if (preg_match("/Android/", $userAgent, $match)) { | |
$isMobile = true; | |
} | |
if (preg_match("/iPhone/", $userAgent, $match)) { | |
$isMobile = true; | |
} | |
if (preg_match("/iPad/", $userAgent, $match)) { | |
$isMobile = true; | |
} | |
if ($isMobile) { | |
$request->setParam('format','mobile'); | |
define('DEVICE', 'MOBILE'); | |
} else { | |
$request->setParam('format','html'); | |
define('DEVICE', 'PC'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment