如何检测 iPhone 是否拥有视网膜屏幕? 有可靠的方法吗? 无论是纯 PHP 还是更喜欢使用 Zend Framework。
如何检测 iPhone 是否拥有视网膜屏幕? 有可靠的方法吗? 无论是纯 PHP 还是更喜欢使用 Zend Framework。
var retina = window.devicePixelRatio > 1;
if (retina)
{
// the user has a retina display
}
else
{
// the user has a non-retina display
}
您必须考虑到,您正在尝试在服务器端获取客户端信息。
似乎您无法使用纯PHP或Zend框架检测显示器。
此外,从客户端访问的用户代理信息可能基于操作系统而不是硬件,因此对您没有帮助。
您可能会对阅读以下文章感兴趣,该文章更加优美和详细地解释了这些问题。
http://www.bdoran.co.uk/2010/07/19/detecting-the-iphone4-and-resolution-with-javascript-or-php/
祝你好运!
Javascript: window.devicePixelRatio
<script language="Javascript">
<!--
document.write('<br>your resolution is' + screen.width + 'x' + screen.height)
//-->
</script>