获取用户登录的设备类型 系统+版本号

WBOY
Freigeben: 2016-07-29 08:59:02
Original
1862 Leute haben es durchsucht
<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>
Nach dem Login kopieren

以上就介绍了获取用户登录的设备类型 系统+版本号,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!