有一个基于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>