Home > php教程 > php手册 > 分享一个检测用户是否用手机(Mobile)访问网站的 PHP 类

分享一个检测用户是否用手机(Mobile)访问网站的 PHP 类

WBOY
Release: 2016-06-13 11:31:03
Original
898 people have browsed it

有一个基于MIT License协议开源的PHP程序

http://code.google.com/p/php-mobile-detect/

程序就是一个文件,下载之后直接引用就可以。

使用方法:

<span><?php</span>
<span>include</span><span>(</span><span>"Mobile_Detect.php"</span><span>)</span><span>;</span>
<span>$detect</span> <span>=</span> <span>new</span> Mobile_Detect<span>(</span><span>)</span><span>;</span>
 
<span>if</span> <span>(</span><span>$detect</span><span>-></span><span>isMobile</span><span>(</span><span>)</span><span>)</span> <span>{</span>
    <span>// any mobile platform</span>
    <span>echo</span> <span>'isMobile'</span><span>;</span>
<span>}</span>
<span>else</span><span>{</span>
    <span>echo</span> <span>'isPC'</span><span>;</span>
<span>}</span>
<span>?></span>
Copy after login
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template