How to determine if the iPhone has a retina display or not?

How to determine if the iPhone has a retina screen or not? Is there a reliable way? Either pure PHP or the preferred Zend Framework method.

+5
source share
4 answers

You should consider the fact that you are trying to get client side information on the server side.

It would seem that you cannot detect a mapping with pure PHP or a Zend map.

In addition, it is similar to UserAgent information from the client that you can get with PHP, it is based on the OS, not hardware, and therefore does not help you.

You may be interested in reading the following article, which more eloquently and in detail explains the problems.

http://www.bdoran.co.uk/2010/07/19/detecting-the-iphone4-and-resolution-with-javascript-or-php/

!

+3

var retina = window.devicePixelRatio > 1;

if (retina)
{
    // the user has a retina display
}
else
{
    // the user has a non-retina display
}
+4

Javascript: window.devicePixelRatio

+2
source

I think that for such a task there will be quite a simple thing, like determining the width of the screen, and the retina displays so many pixels in width that a simple check will immediately tell you whether a regular display or retina will be displayed. PHP does not have this feature out of the box, but Javascript does.

Here's how:

<script language="Javascript">     
<!--     
document.write('<br>your resolution is' + screen.width + 'x' + screen.height)     
//-->     
</script> 
+1
source

All Articles