우리가 우리의 바탕 화면에 탐색 서버는 우리가 바탕 화면에 있고 단순히 기본을 보낼 것을 감지 (데스크톱) 우리는 다른 클라이언트를 사용하는 경우 다른 한편으로 responsive.but되지 FB의 인덱스 페이지 태블릿이나 모바일 서버가이를 감지하면 웹 documnet을 fb의 다른 모바일 친화적 인 페이지로 리디렉션합니다. 그렇지 않으면 데스크탑 페이지와 동일하지 않은 CSS가 변경됩니다. 서버가 우리 장치와 브라우저를 감지 함을 의미합니다. 검색에 사용할 수있는 PHP 탐지 스크립트는 다음과 같습니다.
//php technique
<?php
$agent = $_SERVER['HTTP_USER_AGENT']; // Put browser name into local variable
if (preg_match("/iPhone/", $agent)) {
header("location: iphone_home.html");
} else if (preg_match("/android/", $agent)) {
header("location: android_home.html");
}?>
//javascript technique
<script language="javascript" type="text/javascript">
var agent = navigator.userAgent.toLowerCase();
if (agent.indexOf('iphone') != -1) { // iPhone Device
// If it is an iPhone put specific code to run here for iPhone users
} else if (agent.indexOf('android') != -1) { // Google phones running Android OS
// If it is a Google phone put specific code to run here for Android users
}
</script>
//php technique to detect OS and browser of user
<?php
$agent = $_SERVER['HTTP_USER_AGENT'];
$browserArray = array(
'Windows Mobile' => 'IEMobile',
'Android Mobile' => 'Android',
'iPhone Mobile' => 'iPhone',
'Firefox' => 'Firefox',
'Google Chrome' => 'Chrome',
'Internet Explorer' => 'MSIE',
'Opera' => 'Opera',
'Safari' => 'Safari'
);
foreach ($browserArray as $k => $v) {
if (preg_match("/$v/", $agent)) {
break;
} else {
$k = "Browser Unknown";
}
}
$browser = $k;
$osArray = array(
'Windows 98' => '(Win98)|(Windows 98)',
'Windows 2000' => '(Windows 2000)|(Windows NT 5.0)',
'Windows ME' => 'Windows ME',
'Windows XP' => '(Windows XP)|(Windows NT 5.1)',
'Windows Vista' => 'Windows NT 6.0',
'Windows 7' => '(Windows NT 6.1)|(Windows NT 7.0)',
'Windows NT 4.0' => '(WinNT)|(Windows NT 4.0)|(WinNT4.0)|(Windows NT)',
'Linux' => '(X11)|(Linux)',
'Mac OS' => '(Mac_PowerPC)|(Macintosh)|(Mac OS)'
);
foreach ($osArray as $k => $v) {
if (preg_match("/$v/", $agent)) {
break;
} else {
$k = "Unknown OS";
}
}
$os = $k;
echo $agent;
echo "<h2>You are using: <em>$browser - $os</em></h2>";
?>
이전 질문/답변을 통해 질문에 대한 답변을 얻을 수 있습니다 - http://stackoverflow.com/questions/15751011/is-there -a-way-to-perform-a-mobile-detect-that-exactly-match-facebooks-mobile –