Skip to content

Instantly share code, notes, and snippets.

@shoyan
Last active December 11, 2015 06:39
Show Gist options
  • Save shoyan/4561150 to your computer and use it in GitHub Desktop.
Save shoyan/4561150 to your computer and use it in GitHub Desktop.
USER_AGENTを見て判断するサンプル
<?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