在我的 PHP 脚本中,我使用 Tera-WURFL api 来获取移动手机的屏幕分辨率 但我得到的结果不正确...这是一个代码...
**<?php
require_once('Tera-Wurfl/TeraWurfl.php');
$wurflObj = new TeraWurfl();
$wurflObj->getDeviceCapabilitiesFromAgent();
echo "Markup: ".$wurflObj->getDeviceCapability("preferred_markup");
// see the display resolution
$width = $wurflObj->getDeviceCapability("resolution_width");
$height = $wurflObj->getDeviceCapability("resolution_height");
echo $_SERVER['HTTP_USER_AGENT'];
echo "<br/>Resolution: $width x $height<br/>";
?>**
我在这里做错了什么?
最佳答案
您可以从以下位置下载和使用免费的 51Degrees.mobi Lite 数据和文档:http://sourceforge.net/projects/fiftyone/?source=directory
您可以使用以下代码来使用 51Degrees.mobi 属性:
<?php
require_once('51Degrees.mobi.php');
$ScreenPixelsHeight = $_51d["ScreenPixelsHeight"];
$ScreenPixelsWidth = $_51d["ScreenPixelsWidth"];
?>
注意:$_51d 数组中存储的所有数据均存储为字符串,您可能需要将 $ScreenPixelsHeight 和 $ScreenPixelsWidth 转换为数字。
关于php - 无法使用 Tera-WURFL 获得正确的手机屏幕尺寸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13492763/