重:首頁網站= http://mobiledetect.net/
重:這個腳本= Mobile_Detect.php
下載腳本的位置:https://github.com/serbanghita/Mobile-DetectPHP - 顯示來自'Detect'數組的結果?
這個腳本功能完美檢測用戶的設備的不同參數。
然而,這是我當前如何檢測這些參數:
// each part of the IF statement is hard-coded = not the way to do this
if($detect->isiOS()){
$usingOS = 'iOS';
}
if($detect->isAndroidOS()){
$usingOS = 'Android';
}
echo 'Your OS is: '.$usingOS;
我的目標是使用foreach來遍歷各種通陣列在這個腳本來確定用戶的設備的參數。我需要「($ detect-> isXXXXOS())」是動態的......(這將基於KEY)。結果將顯示KEY。但檢測將基於VALUE。
此外,由於我的網頁使用REQUIRE訪問此腳本...在Mobile_Script.php腳本中,數組是「受保護的」。我認爲這也會造成我的問題(但我不確定)。
任何幫助表示讚賞。
要求使得陣列保護?沒有理解你的意思。 – Anigel
爲什麼不使用一系列if/else if語句,一旦找到實際設備就會停止。而foreach將迭代遍歷它們,無論何時發現設備類型 – Paddyd