我在互联网上搜索答案,但当我找不到答案时,我发布了我的问题。有什么方法可以检测网站是否被电脑或手机使用? 我不想使用 TeraWurfl。 只是一段可以返回 computer
的代码。或mobile
?有人编写过这样的代码吗?
最佳答案
我使用了mobile_Detect.php
,它解决了我的问题。我使用了以下代码。
<?php
require_once '../Mobile_Detect.php';
$detect = new Mobile_Detect;
echo $deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');
?>
关于javascript - 如何在不使用 TeraWurfl 的情况下检测网站是否正在通过移动设备或计算机使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34868940/