取得使用者登入的設備類型 系統+版本號

WBOY
發布: 2016-07-29 08:59:02
原創
1862 人瀏覽過
<span>function </span><span>equipmentSystem(){
</span><span>$agent </span><span>= </span><span>isset</span><span>(</span><span>$_SERVER</span><span>[</span><span>'HTTP_USER_AGENT'</span><span>]) ? </span><span>$_SERVER</span><span>[</span><span>'HTTP_USER_AGENT'</span><span>] : </span><span>''</span><span>;
</span><span>if</span><span>(</span><span><em>stristr</em></span><span>(</span><span>$agent</span><span>,</span><span>'iPad'</span><span>)) {
</span><span>$fb_fs </span><span>= </span><span>"iPad"</span><span>;
</span><span>    }</span><span>else if</span><span>(</span><span><em>preg_match</em></span><span>(</span><span>'/Android (([0-9_.]{1,3})+)/i'</span><span>,</span><span>$agent</span><span>,</span><span>$version</span><span>)) {
</span><span>$fb_fs </span><span>= </span><span>"</span><span>手机</span><span>(Android "</span><span>.</span><span>$version</span><span>[</span><span>1</span><span>].</span><span>")"</span><span>;
</span><span>    }</span><span>else if</span><span>(</span><span><em>stristr</em></span><span>(</span><span>$agent</span><span>,</span><span>'Linux'</span><span>)){
</span><span>$fb_fs </span><span>= </span><span>"</span><span>电脑</span><span>(Linux)"</span><span>;
</span><span>    }</span><span>else if</span><span>(</span><span><em>preg_match</em></span><span>(</span><span>'/iPhone OS (([0-9_.]{1,3})+)/i'</span><span>,</span><span>$agent</span><span>,</span><span>$version</span><span>)){
</span><span>$fb_fs </span><span>= </span><span>"</span><span>手机</span><span>(iPhone "</span><span>.</span><span>$version</span><span>[</span><span>1</span><span>].</span><span>")"</span><span>;
</span><span>    }</span><span>else if</span><span>(</span><span><em>preg_match</em></span><span>(</span><span>'/Mac OS X (([0-9_.]{1,5})+)/i'</span><span>,</span><span>$agent</span><span>,</span><span>$version</span><span>)){
</span><span>$fb_fs </span><span>= </span><span>"</span><span>电脑</span><span>(OS X "</span><span>.</span><span>$version</span><span>[</span><span>1</span><span>].</span><span>")"</span><span>;
</span><span>    }</span><span>else if</span><span>(</span><span><em>preg_match</em></span><span>(</span><span>'/unix/i'</span><span>,</span><span>$agent</span><span>)){
</span><span>$fb_fs </span><span>= </span><span>"Unix"</span><span>;
</span><span>    }</span><span>else if</span><span>(</span><span><em>preg_match</em></span><span>(</span><span>'/windows/i'</span><span>,</span><span>$agent</span><span>)){
</span><span>$fb_fs </span><span>= </span><span>"</span><span>电脑</span><span>(Windows)"</span><span>;
</span><span>    }</span><span>else</span><span>{
</span><span>$fb_fs </span><span>= </span><span>"</span><span>未知</span><span>(Unknown)"</span><span>;
</span><span>    }</span><span>return </span><span>$fb_fs</span><span>;</span><span>}</span>
登入後複製

以上就介紹了取得使用者登入的裝置類型 系統+版本號,包括了方面的內容,希望對PHP教學有興趣的朋友有所幫助。

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!